<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class Net::IMAP - net-imap: Ruby Standard Library Documentation</title>


<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<script src="../js/jquery-3.2.0.min.js"></script>

<script src="../js/vue.min.js"></script>
<script src="../js/js.cookie.min.js"></script>

<link href="../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../css/rdoc.css" rel="stylesheet">
<link href="../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
  var darkModeCsseHref = "../css/rdoc-dm.css"
  var defaultModeCssHref = "../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    
<div class="nav-section">
  <h3>Table of Contents</h3>

  <ul class="link-list" role="directory">
    <li><a href="#class-Net::IMAP-label-IMAP+Overview">IMAP Overview</a>
    <li><a href="#class-Net::IMAP-label-Sequence+numbers+and+UIDs">Sequence numbers and UIDs</a>
    <li><a href="#class-Net::IMAP-label-Server+capabilities+and+protocol+extensions">Server capabilities and protocol extensions</a>
    <li><a href="#class-Net::IMAP-label-Examples+of+Usage">Examples of Usage</a>
    <li><a href="#class-Net::IMAP-label-List+sender+and+subject+of+all+recent+messages+in+the+default+mailbox">List sender and subject of all recent messages in the default mailbox</a>
    <li><a href="#class-Net::IMAP-label-Move+all+messages+from+April+2003+from+-22Mail-2Fsent-mail-22+to+-22Mail-2Fsent-apr03-22">Move all messages from April 2003 from “Mail/sent-mail” to “Mail/sent-apr03”</a>
    <li><a href="#class-Net::IMAP-label-Thread+Safety">Thread Safety</a>
    <li><a href="#class-Net::IMAP-label-Errors">Errors</a>
    <li><a href="#class-Net::IMAP-label-What-27s+here-3F">What’s here?</a>
    <li><a href="#class-Net::IMAP-label-Connection+control+methods">Connection control methods</a>
    <li><a href="#class-Net::IMAP-label-Core+IMAP+commands">Core IMAP commands</a>
    <li><a href="#class-Net::IMAP-label-IMAP+commands+for+any+state">IMAP commands for any state</a>
    <li><a href="#class-Net::IMAP-label-IMAP+commands+for+the+-22Not+Authenticated-22+state">IMAP commands for the “Not Authenticated” state</a>
    <li><a href="#class-Net::IMAP-label-IMAP+commands+for+the+-22Authenticated-22+state">IMAP commands for the “Authenticated” state</a>
    <li><a href="#class-Net::IMAP-label-IMAP+commands+for+the+-22Selected-22+state">IMAP commands for the “Selected” state</a>
    <li><a href="#class-Net::IMAP-label-IMAP+commands+for+the+-22Logout-22+state">IMAP commands for the “Logout” state</a>
    <li><a href="#class-Net::IMAP-label-Supported+IMAP+extensions">Supported IMAP extensions</a>
    <li><a href="#class-Net::IMAP-label-RFC9051-3A+IMAP4rev2">RFC9051: <code>IMAP4rev2</code></a>
    <li><a href="#class-Net::IMAP-label-RFC2087-3A+QUOTA">RFC2087: <code>QUOTA</code></a>
    <li><a href="#class-Net::IMAP-label-RFC2177-3A+IDLE">RFC2177: <code>IDLE</code></a>
    <li><a href="#class-Net::IMAP-label-RFC2342-3A+NAMESPACE">RFC2342: <code>NAMESPACE</code></a>
    <li><a href="#class-Net::IMAP-label-RFC2971-3A+ID">RFC2971: <code>ID</code></a>
    <li><a href="#class-Net::IMAP-label-RFC3691-3A+UNSELECT">RFC3691: <code>UNSELECT</code></a>
    <li><a href="#class-Net::IMAP-label-RFC4314-3A+ACL">RFC4314: <code>ACL</code></a>
    <li><a href="#class-Net::IMAP-label-RFC4315-3A+UIDPLUS">RFC4315: <code>UIDPLUS</code></a>
    <li><a href="#class-Net::IMAP-label-RFC5256-3A+SORT">RFC5256: <code>SORT</code></a>
    <li><a href="#class-Net::IMAP-label-RFC5256-3A+THREAD">RFC5256: <code>THREAD</code></a>
    <li><a href="#class-Net::IMAP-label-XLIST+-28non-standard-2C+deprecated-29"><code>XLIST</code> (non-standard, deprecated)</a>
    <li><a href="#class-Net::IMAP-label-RFC6851-3A+MOVE">RFC6851: <code>MOVE</code></a>
    <li><a href="#class-Net::IMAP-label-Handling+server+responses">Handling server responses</a>
    <li><a href="#class-Net::IMAP-label-References">References</a>
    <li><a href="#class-Net::IMAP-label-Message+envelope+and+body+structure">Message envelope and body structure</a>
    <li><a href="#class-Net::IMAP-label-Supported+IMAP+Extensions">Supported IMAP Extensions</a>
    <li><a href="#class-Net::IMAP-label-IANA+registries">IANA registries</a>
  </ul>
</div>


    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
<div id="sections-section" class="nav-section">
  <h3>Sections</h3>

  <ul class="link-list" role="directory">
      <li><a href="#5Buntitled-5D"></a></li>
      <li><a href="#Basic+Mailbox+Attributes">Basic Mailbox Attributes</a></li>
      <li><a href="#Mailbox+role+attributes">Mailbox role attributes</a></li>
      <li><a href="#System+Flags">System Flags</a></li>
  </ul>
</div>

        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Protocol
</div>

        
<div id="includes-section" class="nav-section">
  <h3>Included Modules</h3>

  <ul class="link-list">
    <li><span class="include">MonitorMixin</span>
    <li><span class="include">OpenSSL</span>
    <li><span class="include">SSL</span>
  </ul>
</div>

        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-debug">::debug</a>
    <li ><a href="#method-c-debug-3D">::debug=</a>
    <li ><a href="#method-c-decode_date">::decode_date</a>
    <li ><a href="#method-c-decode_datetime">::decode_datetime</a>
    <li ><a href="#method-c-decode_time">::decode_time</a>
    <li ><a href="#method-c-decode_utf7">::decode_utf7</a>
    <li ><a href="#method-c-default_imap_port">::default_imap_port</a>
    <li ><a href="#method-c-default_imaps_port">::default_imaps_port</a>
    <li ><a href="#method-c-default_port">::default_port</a>
    <li ><a href="#method-c-default_ssl_port">::default_ssl_port</a>
    <li ><a href="#method-c-default_tls_port">::default_tls_port</a>
    <li ><a href="#method-c-encode_date">::encode_date</a>
    <li ><a href="#method-c-encode_datetime">::encode_datetime</a>
    <li ><a href="#method-c-encode_time">::encode_time</a>
    <li ><a href="#method-c-encode_utf7">::encode_utf7</a>
    <li ><a href="#method-c-format_date">::format_date</a>
    <li ><a href="#method-c-format_datetime">::format_datetime</a>
    <li ><a href="#method-c-format_time">::format_time</a>
    <li class="calls-super" ><a href="#method-c-new">::new</a>
    <li ><a href="#method-c-parse_date">::parse_date</a>
    <li ><a href="#method-c-parse_datetime">::parse_datetime</a>
    <li ><a href="#method-c-parse_time">::parse_time</a>
    <li ><a href="#method-i-add_response_handler">#add_response_handler</a>
    <li ><a href="#method-i-append">#append</a>
    <li ><a href="#method-i-authenticate">#authenticate</a>
    <li ><a href="#method-i-capability">#capability</a>
    <li ><a href="#method-i-check">#check</a>
    <li ><a href="#method-i-close">#close</a>
    <li ><a href="#method-i-copy">#copy</a>
    <li ><a href="#method-i-copy_internal">#copy_internal</a>
    <li ><a href="#method-i-create">#create</a>
    <li ><a href="#method-i-create_ssl_params">#create_ssl_params</a>
    <li ><a href="#method-i-delete">#delete</a>
    <li ><a href="#method-i-disconnect">#disconnect</a>
    <li ><a href="#method-i-disconnected-3F">#disconnected?</a>
    <li ><a href="#method-i-examine">#examine</a>
    <li ><a href="#method-i-expunge">#expunge</a>
    <li ><a href="#method-i-fetch">#fetch</a>
    <li ><a href="#method-i-fetch_internal">#fetch_internal</a>
    <li ><a href="#method-i-generate_tag">#generate_tag</a>
    <li ><a href="#method-i-get_response">#get_response</a>
    <li ><a href="#method-i-get_tagged_response">#get_tagged_response</a>
    <li ><a href="#method-i-getacl">#getacl</a>
    <li ><a href="#method-i-getquota">#getquota</a>
    <li ><a href="#method-i-getquotaroot">#getquotaroot</a>
    <li ><a href="#method-i-id">#id</a>
    <li ><a href="#method-i-idle">#idle</a>
    <li ><a href="#method-i-idle_done">#idle_done</a>
    <li ><a href="#method-i-list">#list</a>
    <li ><a href="#method-i-login">#login</a>
    <li ><a href="#method-i-logout">#logout</a>
    <li ><a href="#method-i-lsub">#lsub</a>
    <li ><a href="#method-i-move">#move</a>
    <li ><a href="#method-i-namespace">#namespace</a>
    <li ><a href="#method-i-noop">#noop</a>
    <li ><a href="#method-i-normalize_searching_criteria">#normalize_searching_criteria</a>
    <li ><a href="#method-i-put_string">#put_string</a>
    <li ><a href="#method-i-receive_responses">#receive_responses</a>
    <li ><a href="#method-i-record_response">#record_response</a>
    <li ><a href="#method-i-remove_response_handler">#remove_response_handler</a>
    <li ><a href="#method-i-rename">#rename</a>
    <li ><a href="#method-i-search">#search</a>
    <li ><a href="#method-i-search_internal">#search_internal</a>
    <li ><a href="#method-i-select">#select</a>
    <li ><a href="#method-i-send_command">#send_command</a>
    <li ><a href="#method-i-send_data">#send_data</a>
    <li ><a href="#method-i-send_date_data">#send_date_data</a>
    <li ><a href="#method-i-send_list_data">#send_list_data</a>
    <li ><a href="#method-i-send_literal">#send_literal</a>
    <li ><a href="#method-i-send_number_data">#send_number_data</a>
    <li ><a href="#method-i-send_quoted_string">#send_quoted_string</a>
    <li ><a href="#method-i-send_string_data">#send_string_data</a>
    <li ><a href="#method-i-send_symbol_data">#send_symbol_data</a>
    <li ><a href="#method-i-send_time_data">#send_time_data</a>
    <li ><a href="#method-i-setacl">#setacl</a>
    <li ><a href="#method-i-setquota">#setquota</a>
    <li ><a href="#method-i-sort">#sort</a>
    <li ><a href="#method-i-sort_internal">#sort_internal</a>
    <li ><a href="#method-i-start_tls_session">#start_tls_session</a>
    <li ><a href="#method-i-starttls">#starttls</a>
    <li ><a href="#method-i-status">#status</a>
    <li ><a href="#method-i-store">#store</a>
    <li ><a href="#method-i-store_internal">#store_internal</a>
    <li ><a href="#method-i-subscribe">#subscribe</a>
    <li ><a href="#method-i-tcp_socket">#tcp_socket</a>
    <li ><a href="#method-i-thread">#thread</a>
    <li ><a href="#method-i-thread_internal">#thread_internal</a>
    <li ><a href="#method-i-uid_copy">#uid_copy</a>
    <li ><a href="#method-i-uid_expunge">#uid_expunge</a>
    <li ><a href="#method-i-uid_fetch">#uid_fetch</a>
    <li ><a href="#method-i-uid_move">#uid_move</a>
    <li ><a href="#method-i-uid_search">#uid_search</a>
    <li ><a href="#method-i-uid_sort">#uid_sort</a>
    <li ><a href="#method-i-uid_store">#uid_store</a>
    <li ><a href="#method-i-uid_thread">#uid_thread</a>
    <li ><a href="#method-i-unselect">#unselect</a>
    <li ><a href="#method-i-unsubscribe">#unsubscribe</a>
    <li ><a href="#method-i-validate_data">#validate_data</a>
    <li ><a href="#method-i-xlist">#xlist</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-Net::IMAP">
    <h1 id="class-Net::IMAP" class="class">
      class Net::IMAP
    </h1>

    <section class="description">
    
<p><a href="IMAP.html"><code>Net::IMAP</code></a> implements Internet Message Access Protocol (IMAP) client functionality.  The protocol is described in [<a href="https://tools.ietf.org/html/rfc3501">IMAP4rev1</a>].</p>

<h2 id="class-Net::IMAP-label-IMAP+Overview">IMAP Overview<span><a href="#class-Net::IMAP-label-IMAP+Overview">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>An IMAP client connects to a server, and then authenticates itself using either <a href="IMAP.html#method-i-authenticate"><code>authenticate</code></a> or <a href="IMAP.html#method-i-login"><code>login</code></a>.  Having authenticated itself, there is a range of commands available to it.  Most work with mailboxes, which may be arranged in an hierarchical namespace, and each of which contains zero or more messages.  How this is implemented on the server is implementation-dependent; on a UNIX server, it will frequently be implemented as files in mailbox format within a hierarchy of directories.</p>

<p>To work on the messages within a mailbox, the client must first select that mailbox, using either <a href="IMAP.html#method-i-select"><code>select</code></a> or <a href="IMAP.html#method-i-examine"><code>examine</code></a> (for read-only access).  Once the client has successfully selected a mailbox, they enter the “<em>selected</em>” state, and that mailbox becomes the <em>current</em> mailbox, on which mail-item related commands implicitly operate.</p>

<h3 id="class-Net::IMAP-label-Sequence+numbers+and+UIDs">Sequence numbers and UIDs<span><a href="#class-Net::IMAP-label-Sequence+numbers+and+UIDs">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Messages have two sorts of identifiers: message sequence numbers and UIDs.</p>

<p>Message sequence numbers number messages within a mailbox from 1 up to the number of items in the mailbox.  If a new message arrives during a session, it receives a sequence number equal to the new size of the mailbox.  If messages are expunged from the mailbox, remaining messages have their sequence numbers “shuffled down” to fill the gaps.</p>

<p>To avoid sequence number race conditions, servers must not expunge messages when no command is in progress, nor when responding to <a href="IMAP.html#method-i-fetch"><code>fetch</code></a>, <a href="IMAP.html#method-i-store"><code>store</code></a>, or <a href="IMAP.html#method-i-search"><code>search</code></a>.  Expunges <em>may</em> be sent during any other command, including <a href="IMAP.html#method-i-uid_fetch"><code>uid_fetch</code></a>, <a href="IMAP.html#method-i-uid_store"><code>uid_store</code></a>, and <a href="IMAP.html#method-i-uid_search"><code>uid_search</code></a>.  The <a href="IMAP.html#method-i-noop"><code>noop</code></a> and <a href="IMAP.html#method-i-idle"><code>idle</code></a> commands are both useful for this side-effect: they allow the server to send all mailbox updates, including expunges.</p>

<p>UIDs, on the other hand, are permanently guaranteed not to identify another message within the same mailbox, even if the existing message is deleted.  UIDs are required to be assigned in ascending (but not necessarily sequential) order within a mailbox; this means that if a non-IMAP client rearranges the order of mail items within a mailbox, the UIDs have to be reassigned.  An IMAP client thus cannot rearrange message orders.</p>

<h3 id="class-Net::IMAP-label-Server+capabilities+and+protocol+extensions">Server capabilities and protocol extensions<span><a href="#class-Net::IMAP-label-Server+capabilities+and+protocol+extensions">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p><a href="IMAP.html"><code>Net::IMAP</code></a> <em>does not modify its behavior</em> according to server <a href="IMAP.html#method-i-capability"><code>capability</code></a>.  Users of the class must check for required capabilities before issuing commands.  Special care should be taken to follow all <a href="IMAP.html#method-i-capability"><code>capability</code></a> requirements for <a href="IMAP.html#method-i-starttls"><code>starttls</code></a>, <a href="IMAP.html#method-i-login"><code>login</code></a>, and <a href="IMAP.html#method-i-authenticate"><code>authenticate</code></a>.</p>

<p>See the <a href="IMAP.html#method-i-capability"><code>capability</code></a> method for more information.</p>

<h2 id="class-Net::IMAP-label-Examples+of+Usage">Examples of Usage<span><a href="#class-Net::IMAP-label-Examples+of+Usage">&para;</a> <a href="#top">&uarr;</a></span></h2>

<h3 id="class-Net::IMAP-label-List+sender+and+subject+of+all+recent+messages+in+the+default+mailbox">List sender and subject of all recent messages in the default mailbox<span><a href="#class-Net::IMAP-label-List+sender+and+subject+of+all+recent+messages+in+the+default+mailbox">&para;</a> <a href="#top">&uarr;</a></span></h3>

<pre class="ruby"><span class="ruby-identifier">imap</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">IMAP</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;mail.example.com&#39;</span>)
<span class="ruby-identifier">imap</span>.<span class="ruby-identifier">authenticate</span>(<span class="ruby-string">&#39;LOGIN&#39;</span>, <span class="ruby-string">&#39;joe_user&#39;</span>, <span class="ruby-string">&#39;joes_password&#39;</span>)
<span class="ruby-identifier">imap</span>.<span class="ruby-identifier">examine</span>(<span class="ruby-string">&#39;INBOX&#39;</span>)
<span class="ruby-identifier">imap</span>.<span class="ruby-identifier">search</span>([<span class="ruby-string">&quot;RECENT&quot;</span>]).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">message_id</span><span class="ruby-operator">|</span>
  <span class="ruby-identifier">envelope</span> = <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-identifier">message_id</span>, <span class="ruby-string">&quot;ENVELOPE&quot;</span>)[<span class="ruby-value">0</span>].<span class="ruby-identifier">attr</span>[<span class="ruby-string">&quot;ENVELOPE&quot;</span>]
  <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{envelope.from[0].name}: \t#{envelope.subject}&quot;</span>
<span class="ruby-keyword">end</span>
</pre>

<h3 id="class-Net::IMAP-label-Move+all+messages+from+April+2003+from+-22Mail-2Fsent-mail-22+to+-22Mail-2Fsent-apr03-22">Move all messages from April 2003 from “Mail/sent-mail” to “Mail/sent-apr03”<span><a href="#class-Net::IMAP-label-Move+all+messages+from+April+2003+from+-22Mail-2Fsent-mail-22+to+-22Mail-2Fsent-apr03-22">&para;</a> <a href="#top">&uarr;</a></span></h3>

<pre class="ruby"><span class="ruby-identifier">imap</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">IMAP</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;mail.example.com&#39;</span>)
<span class="ruby-identifier">imap</span>.<span class="ruby-identifier">authenticate</span>(<span class="ruby-string">&#39;LOGIN&#39;</span>, <span class="ruby-string">&#39;joe_user&#39;</span>, <span class="ruby-string">&#39;joes_password&#39;</span>)
<span class="ruby-identifier">imap</span>.<span class="ruby-identifier">select</span>(<span class="ruby-string">&#39;Mail/sent-mail&#39;</span>)
<span class="ruby-keyword">if</span> <span class="ruby-keyword">not</span> <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">list</span>(<span class="ruby-string">&#39;Mail/&#39;</span>, <span class="ruby-string">&#39;sent-apr03&#39;</span>)
  <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">create</span>(<span class="ruby-string">&#39;Mail/sent-apr03&#39;</span>)
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">imap</span>.<span class="ruby-identifier">search</span>([<span class="ruby-string">&quot;BEFORE&quot;</span>, <span class="ruby-string">&quot;30-Apr-2003&quot;</span>, <span class="ruby-string">&quot;SINCE&quot;</span>, <span class="ruby-string">&quot;1-Apr-2003&quot;</span>]).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">message_id</span><span class="ruby-operator">|</span>
  <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">copy</span>(<span class="ruby-identifier">message_id</span>, <span class="ruby-string">&quot;Mail/sent-apr03&quot;</span>)
  <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">store</span>(<span class="ruby-identifier">message_id</span>, <span class="ruby-string">&quot;+FLAGS&quot;</span>, [<span class="ruby-value">:Deleted</span>])
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">imap</span>.<span class="ruby-identifier">expunge</span>
</pre>

<h2 id="class-Net::IMAP-label-Thread+Safety">Thread Safety<span><a href="#class-Net::IMAP-label-Thread+Safety">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p><a href="IMAP.html"><code>Net::IMAP</code></a> supports concurrent threads. For example,</p>

<pre class="ruby"><span class="ruby-identifier">imap</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">IMAP</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;imap.foo.net&quot;</span>, <span class="ruby-string">&quot;imap2&quot;</span>)
<span class="ruby-identifier">imap</span>.<span class="ruby-identifier">authenticate</span>(<span class="ruby-string">&quot;cram-md5&quot;</span>, <span class="ruby-string">&quot;bar&quot;</span>, <span class="ruby-string">&quot;password&quot;</span>)
<span class="ruby-identifier">imap</span>.<span class="ruby-identifier">select</span>(<span class="ruby-string">&quot;inbox&quot;</span>)
<span class="ruby-identifier">fetch_thread</span> = <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">start</span> { <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>, <span class="ruby-string">&quot;UID&quot;</span>) }
<span class="ruby-identifier">search_result</span> = <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">search</span>([<span class="ruby-string">&quot;BODY&quot;</span>, <span class="ruby-string">&quot;hello&quot;</span>])
<span class="ruby-identifier">fetch_result</span> = <span class="ruby-identifier">fetch_thread</span>.<span class="ruby-identifier">value</span>
<span class="ruby-identifier">imap</span>.<span class="ruby-identifier">disconnect</span>
</pre>

<p>This script invokes the FETCH command and the SEARCH command concurrently.</p>

<h2 id="class-Net::IMAP-label-Errors">Errors<span><a href="#class-Net::IMAP-label-Errors">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>An IMAP server can send three different types of responses to indicate failure:</p>
<dl class="rdoc-list note-list"><dt>NO
<dd>
<p>the attempted command could not be successfully completed.  For instance, the username/password used for logging in are incorrect; the selected mailbox does not exist; etc.</p>
</dd><dt>BAD
<dd>
<p>the request from the client does not follow the server’s understanding of the IMAP protocol.  This includes attempting commands from the wrong client state; for instance, attempting to perform a SEARCH command without having SELECTed a current mailbox.  It can also signal an internal server failure (such as a disk crash) has occurred.</p>
</dd><dt>BYE
<dd>
<p>the server is saying goodbye.  This can be part of a normal logout sequence, and can be used as part of a login sequence to indicate that the server is (for some reason) unwilling to accept your connection.  As a response to any other command, it indicates either that the server is shutting down, or that the server is timing out the client connection due to inactivity.</p>
</dd></dl>

<p>These three error response are represented by the errors <a href="IMAP/NoResponseError.html"><code>Net::IMAP::NoResponseError</code></a>, <a href="IMAP/BadResponseError.html"><code>Net::IMAP::BadResponseError</code></a>, and <a href="IMAP/ByeResponseError.html"><code>Net::IMAP::ByeResponseError</code></a>, all of which are subclasses of <a href="IMAP/ResponseError.html"><code>Net::IMAP::ResponseError</code></a>.  Essentially, all methods that involve sending a request to the server can generate one of these errors. Only the most pertinent instances have been documented below.</p>

<p>Because the <a href="IMAP.html"><code>IMAP</code></a> class uses Sockets for communication, its methods are also susceptible to the various errors that can occur when working with sockets.  These are generally represented as Errno errors.  For instance, any method that involves sending a request to the server and/or receiving a response from it could raise an Errno::EPIPE error if the network connection unexpectedly goes down.  See the socket(7), ip(7), tcp(7), socket(2), connect(2), and associated man pages.</p>

<p>Finally, a <a href="IMAP/DataFormatError.html"><code>Net::IMAP::DataFormatError</code></a> is thrown if low-level data is found to be in an incorrect format (for instance, when converting between UTF-8 and UTF-16), and <a href="IMAP/ResponseParseError.html"><code>Net::IMAP::ResponseParseError</code></a> is thrown if a server response is non-parseable.</p>

<h2 id="class-Net::IMAP-label-What-27s+here-3F">What’s here?<span><a href="#class-Net::IMAP-label-What-27s+here-3F">&para;</a> <a href="#top">&uarr;</a></span></h2>
<ul><li>
<p><a href="IMAP.html#class-Net::IMAP-label-Connection+control+methods">Connection control</a></p>
</li><li>
<p><a href="IMAP.html#class-Net::IMAP-label-Core+IMAP+commands">Core IMAP commands</a></p>
<ul><li>
<p><a href="IMAP.html#class-Net::IMAP-label-IMAP+commands+for+any+state">…for any state</a></p>
</li><li>
<p><a href="IMAP.html#class-Net::IMAP-label-IMAP+commands+for+the+-22Not+Authenticated-22+state">…for the “not authenticated” state</a></p>
</li><li>
<p><a href="IMAP.html#class-Net::IMAP-label-IMAP+commands+for+the+-22Authenticated-22+state">…for the “authenticated” state</a></p>
</li><li>
<p><a href="IMAP.html#class-Net::IMAP-label-IMAP+commands+for+the+-22Selected-22+state">…for the “selected” state</a></p>
</li><li>
<p><a href="IMAP.html#class-Net::IMAP-label-IMAP+commands+for+the+-22Logout-22+state">…for the “logout” state</a></p>
</li></ul>
</li><li>
<p><a href="IMAP.html#class-Net::IMAP-label-Supported+IMAP+extensions">Supported IMAP extensions</a></p>
</li><li>
<p><a href="IMAP.html#class-Net::IMAP-label-Handling+server+responses">Handling server responses</a></p>
</li></ul>

<h3 id="class-Net::IMAP-label-Connection+control+methods">Connection control methods<span><a href="#class-Net::IMAP-label-Connection+control+methods">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="IMAP.html#method-c-new"><code>Net::IMAP.new</code></a>: A new client connects immediately and waits for a successful server greeting before returning the new client object.</p>
</li><li>
<p><a href="IMAP.html#method-i-starttls"><code>starttls</code></a>: Asks the server to upgrade a clear-text connection to use TLS.</p>
</li><li>
<p><a href="IMAP.html#method-i-logout"><code>logout</code></a>: Tells the server to end the session. Enters the “<em>logout</em>” state.</p>
</li><li>
<p><a href="IMAP.html#method-i-disconnect"><code>disconnect</code></a>: Disconnects the connection (without sending <a href="IMAP.html#method-i-logout"><code>logout</code></a> first).</p>
</li><li>
<p><a href="IMAP.html#method-i-disconnected-3F"><code>disconnected?</code></a>: True if the connection has been closed.</p>
</li></ul>

<h3 id="class-Net::IMAP-label-Core+IMAP+commands">Core IMAP commands<span><a href="#class-Net::IMAP-label-Core+IMAP+commands">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>The following commands are defined either by the [<a href="https://tools.ietf.org/html/rfc3501">IMAP4rev1</a>] base specification, or by one of the following extensions: [<a href="https://tools.ietf.org/html/rfc2177">IDLE</a>], [<a href="https://tools.ietf.org/html/rfc2342">NAMESPACE</a>], [<a href="https://tools.ietf.org/html/rfc3691">UNSELECT</a>], [<a href="https://tools.ietf.org/html/rfc6851">MOVE</a>]. These extensions are widely supported by modern IMAP4rev1 servers and have all been integrated into [<a href="https://tools.ietf.org/html/rfc9051">IMAP4rev2</a>]. <em>Note: Net::IMAP doesn’t fully support IMAP4rev2 yet.</em></p>

<h4 id="class-Net::IMAP-label-IMAP+commands+for+any+state">IMAP commands for any state<span><a href="#class-Net::IMAP-label-IMAP+commands+for+any+state">&para;</a> <a href="#top">&uarr;</a></span></h4>
<ul><li>
<p><a href="IMAP.html#method-i-capability"><code>capability</code></a>: Returns the server’s capabilities as an array of strings.</p>

<p><em>Capabilities may change after</em> <a href="IMAP.html#method-i-starttls"><code>starttls</code></a>, <a href="IMAP.html#method-i-authenticate"><code>authenticate</code></a>, or <a href="IMAP.html#method-i-login"><code>login</code></a> <em>and cached capabilities must be reloaded.</em></p>
</li><li>
<p><a href="IMAP.html#method-i-noop"><code>noop</code></a>: Allows the server to send unsolicited untagged <a href="IMAP.html#attribute-i-responses"><code>responses</code></a>.</p>
</li><li>
<p><a href="IMAP.html#method-i-logout"><code>logout</code></a>: Tells the server to end the session. Enters the “<em>logout</em>” state.</p>
</li></ul>

<h4 id="class-Net::IMAP-label-IMAP+commands+for+the+-22Not+Authenticated-22+state">IMAP commands for the “Not Authenticated” state<span><a href="#class-Net::IMAP-label-IMAP+commands+for+the+-22Not+Authenticated-22+state">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>In addition to the universal commands, the following commands are valid in the “<em>not authenticated</em>” state:</p>
<ul><li>
<p><a href="IMAP.html#method-i-starttls"><code>starttls</code></a>: Upgrades a clear-text connection to use TLS.</p>

<p><em>Requires the <code>STARTTLS</code> capability.</em></p>
</li><li>
<p><a href="IMAP.html#method-i-authenticate"><code>authenticate</code></a>: Identifies the client to the server using a <a href="https://www.iana.org/assignments/sasl-mechanisms/sasl-mechanisms.xhtml">SASL mechanism</a>. Enters the “<em>authenticated</em>” state.</p>

<p><em>Requires the <code>AUTH=#{mechanism}</code> capability for the chosen mechanism.</em></p>
</li><li>
<p><a href="IMAP.html#method-i-login"><code>login</code></a>: Identifies the client to the server using a plain text password. Using <a href="IMAP.html#method-i-authenticate"><code>authenticate</code></a> is generally preferred.  Enters the “<em>authenticated</em>” state.</p>

<p><em>The <code>LOGINDISABLED</code> capability</em> <strong>must NOT</strong> <em>be listed.</em></p>
</li></ul>

<h4 id="class-Net::IMAP-label-IMAP+commands+for+the+-22Authenticated-22+state">IMAP commands for the “Authenticated” state<span><a href="#class-Net::IMAP-label-IMAP+commands+for+the+-22Authenticated-22+state">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>In addition to the universal commands, the following commands are valid in the “<em>authenticated</em>” state:</p>
<ul><li>
<p><a href="IMAP.html#method-i-select"><code>select</code></a>:  Open a mailbox and enter the “<em>selected</em>” state.</p>
</li><li>
<p><a href="IMAP.html#method-i-examine"><code>examine</code></a>: Open a mailbox read-only, and enter the “<em>selected</em>” state.</p>
</li><li>
<p><a href="IMAP.html#method-i-create"><code>create</code></a>: Creates a new mailbox.</p>
</li><li>
<p><a href="IMAP.html#method-i-delete"><code>delete</code></a>: Permanently remove a mailbox.</p>
</li><li>
<p><a href="IMAP.html#method-i-rename"><code>rename</code></a>: Change the name of a mailbox.</p>
</li><li>
<p><a href="IMAP.html#method-i-subscribe"><code>subscribe</code></a>: Adds a mailbox to the “subscribed” set.</p>
</li><li>
<p><a href="IMAP.html#method-i-unsubscribe"><code>unsubscribe</code></a>: Removes a mailbox from the “subscribed” set.</p>
</li><li>
<p><a href="IMAP.html#method-i-list"><code>list</code></a>: Returns names and attributes of mailboxes matching a given pattern.</p>
</li><li>
<p><a href="IMAP.html#method-i-namespace"><code>namespace</code></a>: Returns mailbox namespaces, with path prefixes and delimiters.</p>

<p><em>Requires the <code>NAMESPACE</code> capability.</em></p>
</li><li>
<p><a href="IMAP.html#method-i-status"><code>status</code></a>: Returns mailbox information, e.g. message count, unseen message count, <code>UIDVALIDITY</code> and <code>UIDNEXT</code>.</p>
</li><li>
<p><a href="IMAP.html#method-i-append"><code>append</code></a>: Appends a message to the end of a mailbox.</p>
</li><li>
<p><a href="IMAP.html#method-i-idle"><code>idle</code></a>: Allows the server to send updates to the client, without the client needing to poll using <a href="IMAP.html#method-i-noop"><code>noop</code></a>.</p>

<p><em>Requires the <code>IDLE</code> capability.</em></p>
</li><li>
<p><a href="IMAP.html#method-i-lsub"><code>lsub</code></a>: Lists mailboxes the user has declared “active” or “subscribed”.</p>
</li></ul>

<h4 id="class-Net::IMAP-label-IMAP+commands+for+the+-22Selected-22+state">IMAP commands for the “Selected” state<span><a href="#class-Net::IMAP-label-IMAP+commands+for+the+-22Selected-22+state">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>In addition to the universal commands and the “authenticated” commands, the following commands are valid in the “<em>selected</em>” state:</p>
<ul><li>
<p><a href="IMAP.html#method-i-close"><code>close</code></a>: Closes the mailbox and returns to the “<em>authenticated</em>” state, expunging deleted messages, unless the mailbox was opened as read-only.</p>
</li><li>
<p><a href="IMAP.html#method-i-unselect"><code>unselect</code></a>: Closes the mailbox and returns to the “<em>authenticated</em>” state, without expunging any messages.</p>

<p><em>Requires the <code>UNSELECT</code> capability.</em></p>
</li><li>
<p><a href="IMAP.html#method-i-expunge"><code>expunge</code></a>: Permanently removes messages which have the Deleted flag set.</p>
</li><li>
<p><a href="IMAP.html#method-i-uid_expunge"><code>uid_expunge</code></a>: Restricts <a href="IMAP.html#method-i-expunge"><code>expunge</code></a> to only remove the specified UIDs.</p>

<p><em>Requires the <code>UIDPLUS</code> capability.</em></p>
</li><li>
<p><a href="IMAP.html#method-i-search"><code>search</code></a>, <a href="IMAP.html#method-i-uid_search"><code>uid_search</code></a>: Returns sequence numbers or UIDs of messages that match the given searching criteria.</p>
</li><li>
<p><a href="IMAP.html#method-i-fetch"><code>fetch</code></a>, <a href="IMAP.html#method-i-uid_fetch"><code>uid_fetch</code></a>: Returns data associated with a set of messages, specified by sequence number or UID.</p>
</li><li>
<p><a href="IMAP.html#method-i-store"><code>store</code></a>, <a href="IMAP.html#method-i-uid_store"><code>uid_store</code></a>: Alters a message’s flags.</p>
</li><li>
<p><a href="IMAP.html#method-i-copy"><code>copy</code></a>, <a href="IMAP.html#method-i-uid_copy"><code>uid_copy</code></a>: Copies the specified messages to the end of the specified destination mailbox.</p>
</li><li>
<p><a href="IMAP.html#method-i-move"><code>move</code></a>, <a href="IMAP.html#method-i-uid_move"><code>uid_move</code></a>: Moves the specified messages to the end of the specified destination mailbox, expunging them from the current mailbox.</p>

<p><em>Requires the <code>MOVE</code> capability.</em></p>
</li><li>
<p><a href="IMAP.html#method-i-check"><code>check</code></a>: Mostly obsolete.  Can be replaced with <a href="IMAP.html#method-i-noop"><code>noop</code></a> or <a href="IMAP.html#method-i-idle"><code>idle</code></a>.</p>
</li></ul>

<h4 id="class-Net::IMAP-label-IMAP+commands+for+the+-22Logout-22+state">IMAP commands for the “Logout” state<span><a href="#class-Net::IMAP-label-IMAP+commands+for+the+-22Logout-22+state">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>No IMAP commands are valid in the <code>logout</code> state.  If the socket is still open, <a href="IMAP.html"><code>Net::IMAP</code></a> will close it after receiving server confirmation. Exceptions will be raised by IMAP commands that have already started and are waiting for a response, as well as any that are called after logout.</p>

<h3 id="class-Net::IMAP-label-Supported+IMAP+extensions">Supported IMAP extensions<span><a href="#class-Net::IMAP-label-Supported+IMAP+extensions">&para;</a> <a href="#top">&uarr;</a></span></h3>

<h4 id="class-Net::IMAP-label-RFC9051-3A+IMAP4rev2">RFC9051: <code>IMAP4rev2</code><span><a href="#class-Net::IMAP-label-RFC9051-3A+IMAP4rev2">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>Although <a href="https://tools.ietf.org/html/rfc9051">IMAP4rev2</a> is <em>not supported yet</em>, <a href="IMAP.html"><code>Net::IMAP</code></a> supports several extensions that have been folded into it: <code>IDLE</code>, <code>MOVE</code>, <code>NAMESPACE</code>, <code>UIDPLUS</code>, and <code>UNSELECT</code>. Commands for these extensions are included with the <a href="IMAP.html#class-Net::IMAP-label-Core+IMAP+commands">Core IMAP commands</a>, above.  Other supported extensons are listed below.</p>

<h4 id="class-Net::IMAP-label-RFC2087-3A+QUOTA">RFC2087: <code>QUOTA</code><span><a href="#class-Net::IMAP-label-RFC2087-3A+QUOTA">&para;</a> <a href="#top">&uarr;</a></span></h4>
<ul><li>
<p><a href="IMAP.html#method-i-getquota"><code>getquota</code></a>: returns the resource usage and limits for a quota root</p>
</li><li>
<p><a href="IMAP.html#method-i-getquotaroot"><code>getquotaroot</code></a>: returns the list of quota roots for a mailbox, as well as their resource usage and limits.</p>
</li><li>
<p><a href="IMAP.html#method-i-setquota"><code>setquota</code></a>: sets the resource limits for a given quota root.</p>
</li></ul>

<h4 id="class-Net::IMAP-label-RFC2177-3A+IDLE">RFC2177: <code>IDLE</code><span><a href="#class-Net::IMAP-label-RFC2177-3A+IDLE">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>Folded into <a href="https://tools.ietf.org/html/rfc9051">IMAP4rev2</a>, so it is also listed with <a href="IMAP.html#class-Net::IMAP-label-Core+IMAP+commands">Core IMAP commands</a>.</p>
<ul><li>
<p><a href="IMAP.html#method-i-idle"><code>idle</code></a>: Allows the server to send updates to the client, without the client needing to poll using <a href="IMAP.html#method-i-noop"><code>noop</code></a>.</p>
</li></ul>

<h4 id="class-Net::IMAP-label-RFC2342-3A+NAMESPACE">RFC2342: <code>NAMESPACE</code><span><a href="#class-Net::IMAP-label-RFC2342-3A+NAMESPACE">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>Folded into <a href="https://tools.ietf.org/html/rfc9051">IMAP4rev2</a>, so it is also listed with <a href="IMAP.html#class-Net::IMAP-label-Core+IMAP+commands">Core IMAP commands</a>.</p>
<ul><li>
<p><a href="IMAP.html#method-i-namespace"><code>namespace</code></a>: Returns mailbox namespaces, with path prefixes and delimiters.</p>
</li></ul>

<h4 id="class-Net::IMAP-label-RFC2971-3A+ID">RFC2971: <code>ID</code><span><a href="#class-Net::IMAP-label-RFC2971-3A+ID">&para;</a> <a href="#top">&uarr;</a></span></h4>
<ul><li>
<p><a href="IMAP.html#method-i-id"><code>id</code></a>: exchanges client and server implementation information.</p>
</li></ul>

<h4 id="class-Net::IMAP-label-RFC3691-3A+UNSELECT">RFC3691: <code>UNSELECT</code><span><a href="#class-Net::IMAP-label-RFC3691-3A+UNSELECT">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>Folded into <a href="https://tools.ietf.org/html/rfc9051">IMAP4rev2</a>, so it is also listed with <a href="IMAP.html#class-Net::IMAP-label-Core+IMAP+commands">Core IMAP commands</a>.</p>
<ul><li>
<p><a href="IMAP.html#method-i-unselect"><code>unselect</code></a>: Closes the mailbox and returns to the “<em>authenticated</em>” state, without expunging any messages.</p>
</li></ul>

<h4 id="class-Net::IMAP-label-RFC4314-3A+ACL">RFC4314: <code>ACL</code><span><a href="#class-Net::IMAP-label-RFC4314-3A+ACL">&para;</a> <a href="#top">&uarr;</a></span></h4>
<ul><li>
<p><a href="IMAP.html#method-i-getacl"><code>getacl</code></a>: lists the authenticated user’s access rights to a mailbox.</p>
</li><li>
<p><a href="IMAP.html#method-i-setacl"><code>setacl</code></a>: sets the access rights for a user on a mailbox</p>
</li><li>
<p><strong><em>Note:</em></strong> <code>DELETEACL</code>, <code>LISTRIGHTS</code>, and <code>MYRIGHTS</code> are not supported yet.</p>
</li></ul>

<h4 id="class-Net::IMAP-label-RFC4315-3A+UIDPLUS">RFC4315: <code>UIDPLUS</code><span><a href="#class-Net::IMAP-label-RFC4315-3A+UIDPLUS">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>Folded into <a href="https://tools.ietf.org/html/rfc9051">IMAP4rev2</a>, so it is also listed with <a href="IMAP.html#class-Net::IMAP-label-Core+IMAP+commands">Core IMAP commands</a>.</p>
<ul><li>
<p><a href="IMAP.html#method-i-uid_expunge"><code>uid_expunge</code></a>: Restricts <a href="IMAP.html#method-i-expunge"><code>expunge</code></a> to only remove the specified UIDs.</p>
</li><li>
<p>Updates <a href="IMAP.html#method-i-select"><code>select</code></a>, <a href="IMAP.html#method-i-examine"><code>examine</code></a> with the <code>UIDNOTSTICKY</code> <a href="IMAP/ResponseCode.html"><code>ResponseCode</code></a></p>
</li><li>
<p>Updates <a href="IMAP.html#method-i-append"><code>append</code></a> with the <code>APPENDUID</code> <a href="IMAP/ResponseCode.html"><code>ResponseCode</code></a></p>
</li><li>
<p>Updates <a href="IMAP.html#method-i-copy"><code>copy</code></a>, <a href="IMAP.html#method-i-move"><code>move</code></a> with the <code>COPYUID</code> <a href="IMAP/ResponseCode.html"><code>ResponseCode</code></a></p>
</li></ul>

<h4 id="class-Net::IMAP-label-RFC5256-3A+SORT">RFC5256: <code>SORT</code><span><a href="#class-Net::IMAP-label-RFC5256-3A+SORT">&para;</a> <a href="#top">&uarr;</a></span></h4>
<ul><li>
<p><a href="IMAP.html#method-i-sort"><code>sort</code></a>, <a href="IMAP.html#method-i-uid_sort"><code>uid_sort</code></a>: An alternate version of <a href="IMAP.html#method-i-search"><code>search</code></a> or <a href="IMAP.html#method-i-uid_search"><code>uid_search</code></a> which sorts the results by specified keys.</p>
</li></ul>

<h4 id="class-Net::IMAP-label-RFC5256-3A+THREAD">RFC5256: <code>THREAD</code><span><a href="#class-Net::IMAP-label-RFC5256-3A+THREAD">&para;</a> <a href="#top">&uarr;</a></span></h4>
<ul><li>
<p><a href="IMAP.html#method-i-thread"><code>thread</code></a>, <a href="IMAP.html#method-i-uid_thread"><code>uid_thread</code></a>: An alternate version of <a href="IMAP.html#method-i-search"><code>search</code></a> or <a href="IMAP.html#method-i-uid_search"><code>uid_search</code></a>, which arranges the results into ordered groups or threads according to a chosen algorithm.</p>
</li></ul>

<h4 id="class-Net::IMAP-label-XLIST+-28non-standard-2C+deprecated-29"><code>XLIST</code> (non-standard, deprecated)<span><a href="#class-Net::IMAP-label-XLIST+-28non-standard-2C+deprecated-29">&para;</a> <a href="#top">&uarr;</a></span></h4>
<ul><li>
<p><a href="IMAP.html#method-i-xlist"><code>xlist</code></a>: replaced by <code>SPECIAL-USE</code> attributes in <a href="IMAP.html#method-i-list"><code>list</code></a> responses.</p>
</li></ul>

<h4 id="class-Net::IMAP-label-RFC6851-3A+MOVE">RFC6851: <code>MOVE</code><span><a href="#class-Net::IMAP-label-RFC6851-3A+MOVE">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>Folded into <a href="https://tools.ietf.org/html/rfc9051">IMAP4rev2</a>, so it is also listed with <a href="IMAP.html#class-Net::IMAP-label-Core+IMAP+commands">Core IMAP commands</a>.</p>
<ul><li>
<p><a href="IMAP.html#method-i-move"><code>move</code></a>, <a href="IMAP.html#method-i-uid_move"><code>uid_move</code></a>: Moves the specified messages to the end of the specified destination mailbox, expunging them from the current mailbox.</p>
</li></ul>

<h3 id="class-Net::IMAP-label-Handling+server+responses">Handling server responses<span><a href="#class-Net::IMAP-label-Handling+server+responses">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="IMAP.html#attribute-i-greeting"><code>greeting</code></a>: The server’s initial untagged response, which can indicate a pre-authenticated connection.</p>
</li><li>
<p><a href="IMAP.html#attribute-i-responses"><code>responses</code></a>: A hash with arrays of unhandled <em>non-<code>nil</em></code> <a href="IMAP/UntaggedResponse.html"><code>UntaggedResponse</code></a> and <a href="IMAP/ResponseCode.html"><code>ResponseCode</code></a> <code>#data</code>, keyed by <code>#name</code>.</p>
</li><li>
<p><a href="IMAP.html#method-i-add_response_handler"><code>add_response_handler</code></a>: Add a block to be called inside the receiver thread with every server response.</p>
</li><li>
<p><a href="IMAP.html#method-i-remove_response_handler"><code>remove_response_handler</code></a>: Remove a previously added response handler.</p>
</li></ul>

<h2 id="class-Net::IMAP-label-References">References<span><a href="#class-Net::IMAP-label-References">&para;</a> <a href="#top">&uarr;</a></span></h2>
<dl class="rdoc-list note-list"><dt>[<a href="https://www.rfc-editor.org/rfc/rfc3501.html">IMAP4rev1</a>]
<dd>
<p>Crispin, M., “INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1”, RFC 3501, DOI 10.17487/RFC3501, March 2003, &lt;<a href="https://www.rfc-editor.org/info/rfc3501">www.rfc-editor.org/info/rfc3501</a>&gt;.</p>
</dd><dt>[<a href="https://www.rfc-editor.org/rfc/rfc4466.html">IMAP-ABNF-EXT</a>]
<dd>
<p>Melnikov, A. and C. Daboo, “Collected Extensions to IMAP4 ABNF”, RFC 4466, DOI 10.17487/RFC4466, April 2006, &lt;<a href="https://www.rfc-editor.org/info/rfc4466">www.rfc-editor.org/info/rfc4466</a>&gt;.</p>

<p><em>Note: Net::IMAP cannot parse the entire RFC4466 grammar yet.</em></p>
</dd><dt>[<a href="https://www.rfc-editor.org/rfc/rfc9051.html">IMAP4rev2</a>]
<dd>
<p>Melnikov, A., Ed., and B. Leiba, Ed., “Internet Message Access Protocol (IMAP) - Version 4rev2”, RFC 9051, DOI 10.17487/RFC9051, August 2021, &lt;<a href="https://www.rfc-editor.org/info/rfc9051">www.rfc-editor.org/info/rfc9051</a>&gt;.</p>

<p><em>Note: Net::IMAP is not fully compatible with IMAP4rev2 yet.</em></p>
</dd><dt>[<a href="https://www.rfc-editor.org/info/rfc2683">IMAP-IMPLEMENTATION</a>]
<dd>
<p>Leiba, B., “IMAP4 Implementation Recommendations”, RFC 2683, DOI 10.17487/RFC2683, September 1999, &lt;<a href="https://www.rfc-editor.org/info/rfc2683">www.rfc-editor.org/info/rfc2683</a>&gt;.</p>
</dd><dt>[<a href="https://www.rfc-editor.org/info/rfc2180">IMAP-MULTIACCESS</a>]
<dd>
<p>Gahrns, M., “IMAP4 Multi-Accessed Mailbox Practice”, RFC 2180, DOI 10.17487/RFC2180, July 1997, &lt;<a href="https://www.rfc-editor.org/info/rfc2180">www.rfc-editor.org/info/rfc2180</a>&gt;.</p>
</dd><dt>[<a href="https://tools.ietf.org/html/rfc2152">UTF7</a>]
<dd>
<p>Goldsmith, D. and M. Davis, “UTF-7 A Mail-Safe Transformation Format of Unicode”, RFC 2152, DOI 10.17487/RFC2152, May 1997, &lt;<a href="https://www.rfc-editor.org/info/rfc2152">www.rfc-editor.org/info/rfc2152</a>&gt;.</p>
</dd></dl>

<h3 id="class-Net::IMAP-label-Message+envelope+and+body+structure">Message envelope and body structure<span><a href="#class-Net::IMAP-label-Message+envelope+and+body+structure">&para;</a> <a href="#top">&uarr;</a></span></h3>
<dl class="rdoc-list note-list"><dt>[<a href="https://tools.ietf.org/html/rfc5322">RFC5322</a>]
<dd>
<p>Resnick, P., Ed., “Internet Message Format”, RFC 5322, DOI 10.17487/RFC5322, October 2008, &lt;<a href="https://www.rfc-editor.org/info/rfc5322">www.rfc-editor.org/info/rfc5322</a>&gt;.</p>

<p><em>Note: obsoletes</em> <a href="https://tools.ietf.org/html/rfc2822">RFC-2822</a><em> (April 2001) and</em> <a href="https://tools.ietf.org/html/rfc822">RFC-822</a><em> (August 1982).</em></p>
</dd><dt>[<a href="https://tools.ietf.org/html/rfc2978">CHARSET</a>]
<dd>
<p>Freed, N. and J. Postel, “IANA Charset Registration Procedures”, BCP 19, RFC 2978, DOI 10.17487/RFC2978, October 2000, &lt;<a href="https://www.rfc-editor.org/info/rfc2978">www.rfc-editor.org/info/rfc2978</a>&gt;.</p>
</dd><dt>[<a href="https://tools.ietf.org/html/rfc2183">DISPOSITION</a>]
<dd>
<p>Troost, R., Dorner, S., and K. Moore, Ed., “Communicating Presentation Information in Internet Messages: The Content-Disposition Header Field”, RFC 2183, DOI 10.17487/RFC2183, August 1997, &lt;<a href="https://www.rfc-editor.org/info/rfc2183">www.rfc-editor.org/info/rfc2183</a>&gt;.</p>
</dd><dt>[<a href="https://tools.ietf.org/html/rfc2045">MIME-IMB</a>]
<dd>
<p>Freed, N. and N. Borenstein, “Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies”, RFC 2045, DOI 10.17487/RFC2045, November 1996, &lt;<a href="https://www.rfc-editor.org/info/rfc2045">www.rfc-editor.org/info/rfc2045</a>&gt;.</p>
</dd><dt>[<a href="https://tools.ietf.org/html/rfc2046">MIME-IMT</a>]
<dd>
<p>Freed, N. and N. Borenstein, “Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types”, RFC 2046, DOI 10.17487/RFC2046, November 1996, &lt;<a href="https://www.rfc-editor.org/info/rfc2046">www.rfc-editor.org/info/rfc2046</a>&gt;.</p>
</dd><dt>[<a href="https://tools.ietf.org/html/rfc2047">MIME-HDRS</a>]
<dd>
<p>Moore, K., “MIME (Multipurpose Internet Mail Extensions) Part Three: Message Header Extensions for Non-ASCII Text”, RFC 2047, DOI 10.17487/RFC2047, November 1996, &lt;<a href="https://www.rfc-editor.org/info/rfc2047">www.rfc-editor.org/info/rfc2047</a>&gt;.</p>
</dd><dt>[<a href="https://tools.ietf.org/html/rfc2231">RFC2231</a>]
<dd>
<p>Freed, N. and K. Moore, “MIME Parameter Value and Encoded Word Extensions: Character Sets, Languages, and Continuations”, RFC 2231, DOI 10.17487/RFC2231, November 1997, &lt;<a href="https://www.rfc-editor.org/info/rfc2231">www.rfc-editor.org/info/rfc2231</a>&gt;.</p>
</dd><dt>[<a href="https://tools.ietf.org/html/rfc6532">I18n-HDRS</a>]
<dd>
<p>Yang, A., Steele, S., and N. Freed, “Internationalized Email Headers”, RFC 6532, DOI 10.17487/RFC6532, February 2012, &lt;<a href="https://www.rfc-editor.org/info/rfc6532">www.rfc-editor.org/info/rfc6532</a>&gt;.</p>
</dd><dt>[<a href="https://www.rfc-editor.org/info/rfc3282">LANGUAGE-TAGS</a>]
<dd>
<p>Alvestrand, H., “Content Language Headers”, RFC 3282, DOI 10.17487/RFC3282, May 2002, &lt;<a href="https://www.rfc-editor.org/info/rfc3282">www.rfc-editor.org/info/rfc3282</a>&gt;.</p>
</dd><dt>[<a href="https://www.rfc-editor.org/info/rfc2557">LOCATION</a>]
<dd>
<p>Palme, J., Hopmann, A., and N. Shelness, “MIME Encapsulation of Aggregate Documents, such as HTML (MHTML)”, RFC 2557, DOI 10.17487/RFC2557, March 1999, &lt;<a href="https://www.rfc-editor.org/info/rfc2557">www.rfc-editor.org/info/rfc2557</a>&gt;.</p>
</dd><dt>[<a href="https://tools.ietf.org/html/rfc1864">MD5</a>]
<dd>
<p>Myers, J. and M. Rose, “The Content-MD5 Header Field”, RFC 1864, DOI 10.17487/RFC1864, October 1995, &lt;<a href="https://www.rfc-editor.org/info/rfc1864">www.rfc-editor.org/info/rfc1864</a>&gt;.</p>
</dd></dl>

<h3 id="class-Net::IMAP-label-Supported+IMAP+Extensions">Supported IMAP Extensions<span><a href="#class-Net::IMAP-label-Supported+IMAP+Extensions">&para;</a> <a href="#top">&uarr;</a></span></h3>
<dl class="rdoc-list note-list"><dt>[<a href="https://tools.ietf.org/html/rfc2087">QUOTA</a>]
<dd>
<p>Myers, J., “IMAP4 QUOTA extension”, RFC 2087, DOI 10.17487/RFC2087, January 1997, &lt;<a href="https://www.rfc-editor.org/info/rfc2087">www.rfc-editor.org/info/rfc2087</a>&gt;.</p>
</dd><dt>[<a href="https://tools.ietf.org/html/rfc2177">IDLE</a>]
<dd>
<p>Leiba, B., “IMAP4 IDLE command”, RFC 2177, DOI 10.17487/RFC2177, June 1997, &lt;<a href="https://www.rfc-editor.org/info/rfc2177">www.rfc-editor.org/info/rfc2177</a>&gt;.</p>
</dd><dt>[<a href="https://tools.ietf.org/html/rfc2342">NAMESPACE</a>]
<dd>
<p>Gahrns, M. and C. Newman, “IMAP4 Namespace”, RFC 2342, DOI 10.17487/RFC2342, May 1998, &lt;<a href="https://www.rfc-editor.org/info/rfc2342">www.rfc-editor.org/info/rfc2342</a>&gt;.</p>
</dd><dt>[<a href="https://tools.ietf.org/html/rfc2971">ID</a>]
<dd>
<p>Showalter, T., “IMAP4 ID extension”, RFC 2971, DOI 10.17487/RFC2971, October 2000, &lt;<a href="https://www.rfc-editor.org/info/rfc2971">www.rfc-editor.org/info/rfc2971</a>&gt;.</p>
</dd><dt>[<a href="https://tools.ietf.org/html/rfc4314">ACL</a>]
<dd>
<p>Melnikov, A., “IMAP4 Access Control List (ACL) Extension”, RFC 4314, DOI 10.17487/RFC4314, December 2005, &lt;<a href="https://www.rfc-editor.org/info/rfc4314">www.rfc-editor.org/info/rfc4314</a>&gt;.</p>
</dd><dt>[<a href="https://www.rfc-editor.org/rfc/rfc4315.html">UIDPLUS</a>]
<dd>
<p>Crispin, M., “Internet Message Access Protocol (IMAP) - UIDPLUS extension”, RFC 4315, DOI 10.17487/RFC4315, December 2005, &lt;<a href="https://www.rfc-editor.org/info/rfc4315">www.rfc-editor.org/info/rfc4315</a>&gt;.</p>
</dd><dt>[<a href="https://tools.ietf.org/html/rfc5256">SORT</a>]
<dd>
<p>Crispin, M. and K. Murchison, “Internet Message Access Protocol - SORT and THREAD Extensions”, RFC 5256, DOI 10.17487/RFC5256, June 2008, &lt;<a href="https://www.rfc-editor.org/info/rfc5256">www.rfc-editor.org/info/rfc5256</a>&gt;.</p>
</dd><dt>[<a href="https://tools.ietf.org/html/rfc5256">THREAD</a>]
<dd>
<p>Crispin, M. and K. Murchison, “Internet Message Access Protocol - SORT and THREAD Extensions”, RFC 5256, DOI 10.17487/RFC5256, June 2008, &lt;<a href="https://www.rfc-editor.org/info/rfc5256">www.rfc-editor.org/info/rfc5256</a>&gt;.</p>
</dd><dt>[<a href="https://www.rfc-editor.org/rfc/rfc5530.html">RFC5530</a>]
<dd>
<p>Gulbrandsen, A., “IMAP Response Codes”, RFC 5530, DOI 10.17487/RFC5530, May 2009, &lt;<a href="https://www.rfc-editor.org/info/rfc5530">www.rfc-editor.org/info/rfc5530</a>&gt;.</p>
</dd><dt>[<a href="https://tools.ietf.org/html/rfc6851">MOVE</a>]
<dd>
<p>Gulbrandsen, A. and N. Freed, Ed., “Internet Message Access Protocol (IMAP) - MOVE Extension”, RFC 6851, DOI 10.17487/RFC6851, January 2013, &lt;<a href="https://www.rfc-editor.org/info/rfc6851">www.rfc-editor.org/info/rfc6851</a>&gt;.</p>
</dd></dl>

<h3 id="class-Net::IMAP-label-IANA+registries">IANA registries<span><a href="#class-Net::IMAP-label-IANA+registries">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="http://www.iana.org/assignments/imap4-capabilities">IMAP Capabilities</a></p>
</li><li>
<p><a href="https://www.iana.org/assignments/imap-response-codes/imap-response-codes.xhtml">IMAP Response Codes</a></p>
</li><li>
<p><a href="https://www.iana.org/assignments/imap-mailbox-name-attributes/imap-mailbox-name-attributes.xhtml">IMAP Mailbox Name Attributes</a></p>
</li><li>
<p><a href="https://www.iana.org/assignments/imap-jmap-keywords/imap-jmap-keywords.xhtml">IMAP and JMAP Keywords</a></p>
</li><li>
<p><a href="https://www.iana.org/assignments/imap-threading-algorithms/imap-threading-algorithms.xhtml">IMAP Threading Algorithms</a></p>
</li><li>
<p><a href="https://www.iana.org/assignments/sasl-mechanisms/sasl-mechanisms.xhtml">SASL Mechanisms and SASL SCRAM Family Mechanisms</a></p>
</li><li>
<p><a href="https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml">Service Name and Transport Protocol Port Number Registry</a>: <code>imap</code>: tcp/143, <code>imaps</code>: tcp/993</p>
</li><li>
<p><a href="https://www.iana.org/assignments/gssapi-service-names/gssapi-service-names.xhtml">GSSAPI/Kerberos/SASL Service Names</a>: <code>imap</code></p>
</li><li>
<p><a href="https://www.iana.org/assignments/character-sets/character-sets.xhtml">Character sets</a></p>
</li></ul>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="STRFDATE">STRFDATE
          <dd><p>strftime/strptime format for an IMAP4 <code>date</code>, excluding optional dquotes. Use via the <a href="IMAP.html#method-c-encode_date"><code>encode_date</code></a> and <a href="IMAP.html#method-c-decode_date"><code>decode_date</code></a> methods.</p>

<pre>date            = date-text / DQUOTE date-text DQUOTE
date-text       = date-day &quot;-&quot; date-month &quot;-&quot; date-year

date-day        = 1*2DIGIT
                    ; Day of month
date-month      = &quot;Jan&quot; / &quot;Feb&quot; / &quot;Mar&quot; / &quot;Apr&quot; / &quot;May&quot; / &quot;Jun&quot; /
                  &quot;Jul&quot; / &quot;Aug&quot; / &quot;Sep&quot; / &quot;Oct&quot; / &quot;Nov&quot; / &quot;Dec&quot;
date-year       = 4DIGIT</pre>
          <dt id="STRFTIME">STRFTIME
          <dd><p>strftime/strptime format for an IMAP4 <code>date-time</code>, including dquotes. See the <a href="IMAP.html#method-c-encode_datetime"><code>encode_datetime</code></a> and <a href="IMAP.html#method-c-decode_datetime"><code>decode_datetime</code></a> methods.</p>

<pre>date-time       = DQUOTE date-day-fixed &quot;-&quot; date-month &quot;-&quot; date-year
                  SP time SP zone DQUOTE

date-day-fixed  = (SP DIGIT) / 2DIGIT
                    ; Fixed-format version of date-day
date-month      = &quot;Jan&quot; / &quot;Feb&quot; / &quot;Mar&quot; / &quot;Apr&quot; / &quot;May&quot; / &quot;Jun&quot; /
                  &quot;Jul&quot; / &quot;Aug&quot; / &quot;Sep&quot; / &quot;Oct&quot; / &quot;Nov&quot; / &quot;Dec&quot;
date-year       = 4DIGIT
time            = 2DIGIT &quot;:&quot; 2DIGIT &quot;:&quot; 2DIGIT
                    ; Hours minutes seconds
zone            = (&quot;+&quot; / &quot;-&quot;) 4DIGIT
                    ; Signed four-digit value of hhmm representing
                    ; hours and minutes east of Greenwich (that is,
                    ; the amount that the given time differs from
                    ; Universal Time).  Subtracting the timezone
                    ; from the given time will give the UT form.
                    ; The Universal Time zone is &quot;+0000&quot;.</pre>

<p>Note that Time.strptime <code>&quot;%d&quot;</code> flexibly parses either space or zero padding.  However, the DQUOTEs are <strong>not</strong> optional.</p>
          <dt id="VERSION">VERSION
          <dd>
        </dl>
        </section>

        <section class="attribute-method-details" class="method-section">
        <header>
        <h3>Attributes</h3>
        </header>

          <div id="attribute-i-greeting" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">greeting</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>Returns the initial greeting the server, an <a href="IMAP/UntaggedResponse.html"><code>UntaggedResponse</code></a>.</p>
              </div>
            </div>
          <div id="attribute-i-idle_response_timeout" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">idle_response_timeout</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>Seconds to wait until an IDLE response is received.</p>
              </div>
            </div>
          <div id="attribute-i-open_timeout" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">open_timeout</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>Seconds to wait until a connection is opened. If the <a href="IMAP.html"><code>IMAP</code></a> object cannot open a connection within this time, it raises a Net::OpenTimeout exception. The default value is 30 seconds.</p>
              </div>
            </div>
          <div id="attribute-i-response_handlers" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">response_handlers</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>Returns all response handlers.</p>
              </div>
            </div>
          <div id="attribute-i-responses" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">responses</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>Returns a hash with arrays of unhandled <em>non-<code>nil</em></code> <a href="IMAP/UntaggedResponse.html#method-i-data"><code>UntaggedResponse#data</code></a> keyed by <a href="IMAP/UntaggedResponse.html#method-i-name"><code>UntaggedResponse#name</code></a>, and <a href="IMAP/ResponseCode.html#method-i-data"><code>ResponseCode#data</code></a> keyed by <a href="IMAP/ResponseCode.html#method-i-name"><code>ResponseCode#name</code></a>.</p>

<p>For example:</p>

<pre class="ruby"><span class="ruby-identifier">imap</span>.<span class="ruby-identifier">select</span>(<span class="ruby-string">&quot;inbox&quot;</span>)
<span class="ruby-identifier">p</span> <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">responses</span>[<span class="ruby-string">&quot;EXISTS&quot;</span>][<span class="ruby-value">-1</span>]
<span class="ruby-comment">#=&gt; 2</span>
<span class="ruby-identifier">p</span> <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">responses</span>[<span class="ruby-string">&quot;UIDVALIDITY&quot;</span>][<span class="ruby-value">-1</span>]
<span class="ruby-comment">#=&gt; 968263756</span>
</pre>
              </div>
            </div>
            </section>


                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-debug" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">debug</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the debug mode.</p>

                              <div class="method-source-code" id="debug-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 740</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">debug</span>
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">@@debug</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-debug-3D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">debug=</span><span
                                class="method-args">(val)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sets the debug mode.</p>

                              <div class="method-source-code" id="debug-3D-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 745</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">debug=</span>(<span class="ruby-identifier">val</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">@@debug</span> = <span class="ruby-identifier">val</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-decode_date" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          decode_date(string) &rarr; Date
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Decodes <code>string</code> as an <a href="IMAP.html"><code>IMAP</code></a> formatted “date”.</p>

<p>Double quotes are optional.  Day of month may be padded with zero or space.  See <a href="IMAP.html#STRFDATE"><code>STRFDATE</code></a>.</p>

                              <div class="method-source-code" id="decode_date-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap/data_encoding.rb, line 89</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">decode_date</span>(<span class="ruby-identifier">string</span>)
  <span class="ruby-identifier">string</span> = <span class="ruby-identifier">string</span>.<span class="ruby-identifier">delete_prefix</span>(<span class="ruby-string">&#39;&quot;&#39;</span>).<span class="ruby-identifier">delete_suffix</span>(<span class="ruby-string">&#39;&quot;&#39;</span>)
  <span class="ruby-constant">Date</span>.<span class="ruby-identifier">strptime</span>(<span class="ruby-identifier">string</span>, <span class="ruby-constant">STRFDATE</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="IMAP.html#method-c-parse_date">parse_date</a>
                            </div>

                          </div>

                  <div id="method-c-decode_datetime" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          decode_datetime(string) &rarr; DateTime
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Decodes <code>string</code> as an IMAP4 formatted “date-time”.</p>

<p>Note that double quotes are not optional.  See <a href="IMAP.html#STRFTIME"><code>STRFTIME</code></a>.</p>

                              <div class="method-source-code" id="decode_datetime-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap/data_encoding.rb, line 106</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">decode_datetime</span>(<span class="ruby-identifier">string</span>)
  <span class="ruby-constant">DateTime</span>.<span class="ruby-identifier">strptime</span>(<span class="ruby-identifier">string</span>, <span class="ruby-constant">STRFTIME</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="IMAP.html#method-c-parse_datetime">parse_datetime</a>
                            </div>

                          </div>

                  <div id="method-c-decode_time" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          decode_time(string) &rarr; Time
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Decodes <code>string</code> as an IMAP4 formatted “date-time”.</p>

<p>Same as <code>decode_datetime</code>, but returning a Time instead.</p>

                              <div class="method-source-code" id="decode_time-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap/data_encoding.rb, line 115</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">decode_time</span>(<span class="ruby-identifier">string</span>)
  <span class="ruby-identifier">decode_datetime</span>(<span class="ruby-identifier">string</span>).<span class="ruby-identifier">to_time</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="IMAP.html#method-c-parse_time">parse_time</a>
                            </div>

                          </div>

                  <div id="method-c-decode_utf7" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">decode_utf7</span><span
                                class="method-args">(s)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Decode a string from modified UTF-7 format to UTF-8.</p>

<p>UTF-7 is a 7-bit encoding of Unicode [UTF7].  <a href="IMAP.html"><code>IMAP</code></a> uses a slightly modified version of this to encode mailbox names containing non-ASCII characters; see [IMAP] section 5.1.3.</p>

<p><a href="IMAP.html"><code>Net::IMAP</code></a> does <em>not</em> automatically encode and decode mailbox names to and from UTF-7.</p>

                              <div class="method-source-code" id="decode_utf7-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap/data_encoding.rb, line 56</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">decode_utf7</span>(<span class="ruby-identifier">s</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/&amp;([A-Za-z0-9+,]+)?-/n</span>) {
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">base64</span> = <span class="ruby-node">$1</span>
      (<span class="ruby-identifier">base64</span>.<span class="ruby-identifier">tr</span>(<span class="ruby-string">&quot;,&quot;</span>, <span class="ruby-string">&quot;/&quot;</span>) <span class="ruby-operator">+</span> <span class="ruby-string">&quot;===&quot;</span>).<span class="ruby-identifier">unpack1</span>(<span class="ruby-string">&quot;m&quot;</span>).<span class="ruby-identifier">encode</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>, <span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_16BE</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-string">&quot;&amp;&quot;</span>
    <span class="ruby-keyword">end</span>
  }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-default_imap_port" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">default_imap_port</span><span
                                class="method-args">()</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="IMAP.html#method-c-default_port">default_port</a>
                            </div>
                          </div>

                  <div id="method-c-default_imaps_port" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">default_imaps_port</span><span
                                class="method-args">()</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="IMAP.html#method-c-default_tls_port">default_tls_port</a>
                            </div>
                          </div>

                  <div id="method-c-default_port" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">default_port</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>The default port for <a href="IMAP.html"><code>IMAP</code></a> connections, port 143</p>

                              <div class="method-source-code" id="default_port-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 750</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">default_port</span>
  <span class="ruby-keyword">return</span> <span class="ruby-constant">PORT</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="IMAP.html#method-c-default_imap_port">default_imap_port</a>
                            </div>

                          </div>

                  <div id="method-c-default_ssl_port" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">default_ssl_port</span><span
                                class="method-args">()</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="IMAP.html#method-c-default_tls_port">default_tls_port</a>
                            </div>
                          </div>

                  <div id="method-c-default_tls_port" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">default_tls_port</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>The default port for IMAPS connections, port 993</p>

                              <div class="method-source-code" id="default_tls_port-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 755</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">default_tls_port</span>
  <span class="ruby-keyword">return</span> <span class="ruby-constant">SSL_PORT</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="IMAP.html#method-c-default_imaps_port">default_imaps_port</a>, <a href="IMAP.html#method-c-default_ssl_port">default_ssl_port</a>
                            </div>

                          </div>

                  <div id="method-c-encode_date" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">encode_date</span><span
                                class="method-args">(date)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Formats <code>time</code> as an IMAP4 date.</p>

                              <div class="method-source-code" id="encode_date-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap/data_encoding.rb, line 79</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">encode_date</span>(<span class="ruby-identifier">date</span>)
  <span class="ruby-identifier">date</span>.<span class="ruby-identifier">to_date</span>.<span class="ruby-identifier">strftime</span> <span class="ruby-constant">STRFDATE</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="IMAP.html#method-c-format_date">format_date</a>
                            </div>

                          </div>

                  <div id="method-c-encode_datetime" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          encode_datetime(time) &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Formats <code>time</code> as an IMAP4 date-time.</p>

                              <div class="method-source-code" id="encode_datetime-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap/data_encoding.rb, line 97</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">encode_datetime</span>(<span class="ruby-identifier">time</span>)
  <span class="ruby-identifier">time</span>.<span class="ruby-identifier">to_datetime</span>.<span class="ruby-identifier">strftime</span> <span class="ruby-constant">STRFTIME</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="IMAP.html#method-c-encode_time">encode_time</a>
                            </div>

                          </div>

                  <div id="method-c-encode_time" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">encode_time</span><span
                                class="method-args">(time)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="IMAP.html#method-c-format_time">format_time</a>
                            </div>

                            <div class="aliases">
                              Alias for: <a href="IMAP.html#method-c-encode_datetime">encode_datetime</a>
                            </div>
                          </div>

                  <div id="method-c-encode_utf7" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">encode_utf7</span><span
                                class="method-args">(s)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Encode a string from UTF-8 format to modified UTF-7.</p>

                              <div class="method-source-code" id="encode_utf7-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap/data_encoding.rb, line 67</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">encode_utf7</span>(<span class="ruby-identifier">s</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/(&amp;)|[^\x20-\x7e]+/</span>) {
    <span class="ruby-keyword">if</span> <span class="ruby-node">$1</span>
      <span class="ruby-string">&quot;&amp;-&quot;</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">base64</span> = [<span class="ruby-node">$&amp;</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_16BE</span>)].<span class="ruby-identifier">pack</span>(<span class="ruby-string">&quot;m0&quot;</span>)
      <span class="ruby-string">&quot;&amp;&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">base64</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&quot;=&quot;</span>).<span class="ruby-identifier">tr</span>(<span class="ruby-string">&quot;/&quot;</span>, <span class="ruby-string">&quot;,&quot;</span>) <span class="ruby-operator">+</span> <span class="ruby-string">&quot;-&quot;</span>
    <span class="ruby-keyword">end</span>
  }.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-string">&quot;ASCII-8BIT&quot;</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-format_date" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">format_date</span><span
                                class="method-args">(date)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="IMAP.html#method-c-encode_date">encode_date</a>
                            </div>
                          </div>

                  <div id="method-c-format_datetime" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">format_datetime</span><span
                                class="method-args">(time)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <dl class="rdoc-list note-list"><dt>DEPRECATED
<dd>
<p>The original version returned incorrectly formatted strings. Strings returned by <a href="IMAP.html#method-c-encode_datetime"><code>encode_datetime</code></a> or <a href="IMAP.html#method-c-format_time"><code>format_time</code></a> use the correct IMAP4rev1 syntax for “date-time”.</p>
</dd></dl>

<p>This invalid format has been temporarily retained for backward compatibility.  A future release will change this method to return the correct format.</p>

                              <div class="method-source-code" id="format_datetime-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap/data_encoding.rb, line 137</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">format_datetime</span>(<span class="ruby-identifier">time</span>)
  <span class="ruby-identifier">warn</span>(<span class="ruby-node">&quot;#{self}.format_datetime incorrectly formats IMAP date-time. &quot;</span> \
       <span class="ruby-node">&quot;Convert to #{self}.encode_datetime or #{self}.format_time instead.&quot;</span>,
       <span class="ruby-value">uplevel:</span> <span class="ruby-value">1</span>, <span class="ruby-value">category:</span> <span class="ruby-value">:deprecated</span>)
  <span class="ruby-identifier">time</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&quot;%d-%b-%Y %H:%M %z&quot;</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-format_time" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">format_time</span><span
                                class="method-args">(time)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="IMAP.html#method-c-encode_time">encode_time</a>
                            </div>
                          </div>

                  <div id="method-c-new" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          Net::IMAP.new(host, options = {})
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates a new <a href="IMAP.html"><code>Net::IMAP</code></a> object and connects it to the specified <code>host</code>.</p>

<p><code>options</code> is an option hash, each key of which is a symbol.</p>

<p>The available options are:</p>
<dl class="rdoc-list note-list"><dt>port
<dd>
<p>Port number (default value is 143 for imap, or 993 for imaps)</p>
</dd><dt>ssl
<dd>
<p>If <code>options[:ssl]</code> is true, then an attempt will be made to use SSL (now TLS) to connect to the server. If <code>options[:ssl]</code> is a hash, it’s passed to OpenSSL::SSL::SSLContext#set_params as parameters.</p>
</dd><dt><a href="IMAP.html#attribute-i-open_timeout"><code>open_timeout</code></a>
<dd>
<p>Seconds to wait until a connection is opened</p>
</dd><dt><a href="IMAP.html#attribute-i-idle_response_timeout"><code>idle_response_timeout</code></a>
<dd>
<p>Seconds to wait until an IDLE response is received</p>
</dd></dl>

<p>The most common errors are:</p>
<dl class="rdoc-list note-list"><dt>Errno::ECONNREFUSED
<dd>
<p>Connection refused by <code>host</code> or an intervening firewall.</p>
</dd><dt>Errno::ETIMEDOUT
<dd>
<p>Connection timed out (possibly due to packets being dropped by an intervening firewall).</p>
</dd><dt>Errno::ENETUNREACH
<dd>
<p>There is no route to that network.</p>
</dd><dt>SocketError
<dd>
<p>Hostname not known or other socket error.</p>
</dd><dt><a href="IMAP/ByeResponseError.html"><code>Net::IMAP::ByeResponseError</code></a>
<dd>
<p>The connected to the host was successful, but it immediately said goodbye.</p>
</dd></dl>
                                <div class="method-calls-super">
                                  Calls superclass method
                                  
                              </div>

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 2009</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">host</span>, <span class="ruby-identifier">port_or_options</span> = {},
               <span class="ruby-identifier">usessl</span> = <span class="ruby-keyword">false</span>, <span class="ruby-identifier">certs</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">verify</span> = <span class="ruby-keyword">true</span>)
  <span class="ruby-keyword">super</span>()
  <span class="ruby-ivar">@host</span> = <span class="ruby-identifier">host</span>
  <span class="ruby-keyword">begin</span>
    <span class="ruby-identifier">options</span> = <span class="ruby-identifier">port_or_options</span>.<span class="ruby-identifier">to_hash</span>
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">NoMethodError</span>
    <span class="ruby-comment"># for backward compatibility</span>
    <span class="ruby-identifier">options</span> = {}
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:port</span>] = <span class="ruby-identifier">port_or_options</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">usessl</span>
      <span class="ruby-identifier">options</span>[<span class="ruby-value">:ssl</span>] = <span class="ruby-identifier">create_ssl_params</span>(<span class="ruby-identifier">certs</span>, <span class="ruby-identifier">verify</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-ivar">@port</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:port</span>] <span class="ruby-operator">||</span> (<span class="ruby-identifier">options</span>[<span class="ruby-value">:ssl</span>] <span class="ruby-operator">?</span> <span class="ruby-constant">SSL_PORT</span> <span class="ruby-operator">:</span> <span class="ruby-constant">PORT</span>)
  <span class="ruby-ivar">@tag_prefix</span> = <span class="ruby-string">&quot;RUBY&quot;</span>
  <span class="ruby-ivar">@tagno</span> = <span class="ruby-value">0</span>
  <span class="ruby-ivar">@open_timeout</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:open_timeout</span>] <span class="ruby-operator">||</span> <span class="ruby-value">30</span>
  <span class="ruby-ivar">@idle_response_timeout</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:idle_response_timeout</span>] <span class="ruby-operator">||</span> <span class="ruby-value">5</span>
  <span class="ruby-ivar">@parser</span> = <span class="ruby-constant">ResponseParser</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-ivar">@sock</span> = <span class="ruby-identifier">tcp_socket</span>(<span class="ruby-ivar">@host</span>, <span class="ruby-ivar">@port</span>)
  <span class="ruby-keyword">begin</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:ssl</span>]
      <span class="ruby-identifier">start_tls_session</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value">:ssl</span>])
      <span class="ruby-ivar">@usessl</span> = <span class="ruby-keyword">true</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-ivar">@usessl</span> = <span class="ruby-keyword">false</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-ivar">@responses</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>([].<span class="ruby-identifier">freeze</span>)
    <span class="ruby-ivar">@tagged_responses</span> = {}
    <span class="ruby-ivar">@response_handlers</span> = []
    <span class="ruby-ivar">@tagged_response_arrival</span> = <span class="ruby-identifier">new_cond</span>
    <span class="ruby-ivar">@continued_command_tag</span> = <span class="ruby-keyword">nil</span>
    <span class="ruby-ivar">@continuation_request_arrival</span> = <span class="ruby-identifier">new_cond</span>
    <span class="ruby-ivar">@continuation_request_exception</span> = <span class="ruby-keyword">nil</span>
    <span class="ruby-ivar">@idle_done_cond</span> = <span class="ruby-keyword">nil</span>
    <span class="ruby-ivar">@logout_command_tag</span> = <span class="ruby-keyword">nil</span>
    <span class="ruby-ivar">@debug_output_bol</span> = <span class="ruby-keyword">true</span>
    <span class="ruby-ivar">@exception</span> = <span class="ruby-keyword">nil</span>

    <span class="ruby-ivar">@greeting</span> = <span class="ruby-identifier">get_response</span>
    <span class="ruby-keyword">if</span> <span class="ruby-ivar">@greeting</span>.<span class="ruby-identifier">nil?</span>
      <span class="ruby-identifier">raise</span> <span class="ruby-constant">Error</span>, <span class="ruby-string">&quot;connection closed&quot;</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">if</span> <span class="ruby-ivar">@greeting</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-string">&quot;BYE&quot;</span>
      <span class="ruby-identifier">raise</span> <span class="ruby-constant">ByeResponseError</span>, <span class="ruby-ivar">@greeting</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-ivar">@client_thread</span> = <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span>
    <span class="ruby-ivar">@receiver_thread</span> = <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">start</span> {
      <span class="ruby-keyword">begin</span>
        <span class="ruby-identifier">receive_responses</span>
      <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Exception</span>
      <span class="ruby-keyword">end</span>
    }
    <span class="ruby-ivar">@receiver_thread_terminating</span> = <span class="ruby-keyword">false</span>
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Exception</span>
    <span class="ruby-ivar">@sock</span>.<span class="ruby-identifier">close</span>
    <span class="ruby-identifier">raise</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-parse_date" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">parse_date</span><span
                                class="method-args">(string)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="IMAP.html#method-c-decode_date">decode_date</a>
                            </div>
                          </div>

                  <div id="method-c-parse_datetime" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">parse_datetime</span><span
                                class="method-args">(string)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="IMAP.html#method-c-decode_datetime">decode_datetime</a>
                            </div>
                          </div>

                  <div id="method-c-parse_time" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">parse_time</span><span
                                class="method-args">(string)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="IMAP.html#method-c-decode_time">decode_time</a>
                            </div>
                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-add_response_handler" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">add_response_handler</span><span
                                class="method-args">(handler = nil, &amp;block)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Adds a response handler. For example, to detect when the server sends a new EXISTS response (which normally indicates new messages being added to the mailbox), add the following handler after selecting the mailbox:</p>

<pre class="ruby"><span class="ruby-identifier">imap</span>.<span class="ruby-identifier">add_response_handler</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">resp</span><span class="ruby-operator">|</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">IMAP</span><span class="ruby-operator">::</span><span class="ruby-constant">UntaggedResponse</span>) <span class="ruby-keyword">and</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-string">&quot;EXISTS&quot;</span>
    <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Mailbox now has #{resp.data} messages&quot;</span>
  <span class="ruby-keyword">end</span>
}
</pre>

                              <div class="method-source-code" id="add_response_handler-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1963</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">add_response_handler</span>(<span class="ruby-identifier">handler</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">&quot;two Procs are passed&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">handler</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">block</span>
  <span class="ruby-ivar">@response_handlers</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">block</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">handler</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-append" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">append</span><span
                                class="method-args">(mailbox, message, flags = nil, date_time = nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends an <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.3.11">APPEND command [IMAP4rev1 §6.3.11]</a> to append the <code>message</code> to the end of the <code>mailbox</code>. The optional <code>flags</code> argument is an array of flags initially passed to the new message.  The optional <code>date_time</code> argument specifies the creation time to assign to the new message; it defaults to the current time.</p>

<p>For example:</p>

<pre class="ruby"><span class="ruby-identifier">imap</span>.<span class="ruby-identifier">append</span>(<span class="ruby-string">&quot;inbox&quot;</span>, <span class="ruby-identifier">&lt;&lt;EOF</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/\n/</span>, <span class="ruby-string">&quot;\r\n&quot;</span>), [<span class="ruby-value">:Seen</span>], <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>)
<span class="ruby-value">Subject: hello
From: shugo@ruby-lang.org
To: shugo@ruby-lang.org

hello world
</span><span class="ruby-identifier">EOF</span>
</pre>

<p>A <a href="IMAP/NoResponseError.html"><code>Net::IMAP::NoResponseError</code></a> is raised if the mailbox does not exist (it is not created automatically), or if the flags, date_time, or message arguments contain errors.</p>

<h5 id="method-i-append-label-Capabilities">Capabilities<span><a href="#method-i-append-label-Capabilities">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p>If <code>UIDPLUS</code> [<a href="https://www.rfc-editor.org/rfc/rfc4315.html">RFC4315</a>] is supported and the destination supports persistent UIDs, the server’s response should include an <code>APPENDUID</code> response code with <a href="IMAP/UIDPlusData.html"><code>UIDPlusData</code></a>. This will report the UIDVALIDITY of the destination mailbox and the assigned UID of the appended message.</p>

                              <div class="method-source-code" id="append-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1487</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">append</span>(<span class="ruby-identifier">mailbox</span>, <span class="ruby-identifier">message</span>, <span class="ruby-identifier">flags</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">date_time</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">args</span> = []
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">flags</span>
    <span class="ruby-identifier">args</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">flags</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">args</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">date_time</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">date_time</span>
  <span class="ruby-identifier">args</span>.<span class="ruby-identifier">push</span>(<span class="ruby-constant">Literal</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">message</span>))
  <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;APPEND&quot;</span>, <span class="ruby-identifier">mailbox</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-authenticate" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          authenticate(mechanism, ...)                               &rarr; ok_resp
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          authenticate(mech, *creds, **props) {|prop, auth| val }    &rarr; ok_resp
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          authenticate(mechanism, authnid, credentials, authzid=nil) &rarr; ok_resp
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          authenticate(mechanism, **properties)                      &rarr; ok_resp
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          authenticate(mechanism) {|propname, authctx| prop_value }  &rarr; ok_resp
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Sends an <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.2.2">AUTHENTICATE command [IMAP4rev1 §6.2.2]</a> to authenticate the client.  If successful, the connection enters the “<em>authenticated</em>” state.</p>

<p><code>mechanism</code> is the name of the SASL authentication mechanism to be used. All other arguments are forwarded to the authenticator for the requested mechanism.  The listed call signatures are suggestions.  <em>The documentation for each individual mechanism must be consulted for its specific parameters.</em></p>

<p>An exception <a href="IMAP/NoResponseError.html"><code>Net::IMAP::NoResponseError</code></a> is raised if authentication fails.</p>

<p>Related: <a href="IMAP.html#method-i-login"><code>login</code></a>, <a href="IMAP.html#method-i-starttls"><code>starttls</code></a></p>

<h4 id="method-i-authenticate-label-Supported+SASL+Mechanisms">Supported <a href="IMAP/SASL.html"><code>SASL</code></a> Mechanisms<span><a href="#method-i-authenticate-label-Supported+SASL+Mechanisms">&para;</a> <a href="#top">&uarr;</a></span></h4>
<dl class="rdoc-list note-list"><dt><code>PLAIN</code>
<dd>
<p>See <a href="IMAP/PlainAuthenticator.html"><code>PlainAuthenticator</code></a>. Login using clear-text username and password.</p>
</dd><dt><code>XOAUTH2</code>
<dd>
<p>See <a href="IMAP/XOauth2Authenticator.html"><code>XOauth2Authenticator</code></a>. Login using a username and OAuth2 access token. Non-standard and obsoleted by <code>OAUTHBEARER</code>, but widely supported.</p>
</dd></dl>

<blockquote>
<p><strong>Deprecated:</strong>  <em>Obsolete mechanisms are available for backwards compatibility.</em></p>

<p>For <code>DIGEST-MD5</code> see <a href="IMAP/DigestMD5Authenticator.html"><code>DigestMD5Authenticator</code></a>.</p>

<p>For <code>LOGIN</code>, see <a href="IMAP/LoginAuthenticator.html"><code>LoginAuthenticator</code></a>.</p>

<p>For <code>CRAM-MD5</code>, see <a href="IMAP/CramMD5Authenticator.html"><code>CramMD5Authenticator</code></a>.</p>

<p><em>Using a deprecated mechanism will print a warning.</em></p>
</blockquote>

<p>See <a href="IMAP/Authenticators.html"><code>Net::IMAP::Authenticators</code></a> for information on plugging in authenticators for other mechanisms.  See the <a href="https://www.iana.org/assignments/sasl-mechanisms/sasl-mechanisms.xhtml">SASL mechanism registry</a> for information on these and other <a href="IMAP/SASL.html"><code>SASL</code></a> mechanisms.</p>

<h5 id="method-i-authenticate-label-Capabilities">Capabilities<span><a href="#method-i-authenticate-label-Capabilities">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p>Clients MUST NOT attempt to authenticate with a mechanism unless <code>&quot;AUTH=#{mechanism}&quot;</code> for that mechanism is a server capability.</p>

<p>Server capabilities may change after <a href="IMAP.html#method-i-starttls"><code>starttls</code></a>, <a href="IMAP.html#method-i-login"><code>login</code></a>, and <a href="IMAP.html#method-i-authenticate"><code>authenticate</code></a>. Cached capabilities <em>must</em> be invalidated after this method completes. The <a href="IMAP/TaggedResponse.html"><code>TaggedResponse</code></a> to <a href="IMAP.html#method-i-authenticate"><code>authenticate</code></a> may include updated capabilities in its <a href="IMAP/ResponseCode.html"><code>ResponseCode</code></a>.</p>

<h5 id="method-i-authenticate-label-Example">Example<span><a href="#method-i-authenticate-label-Example">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p>If the authenticators ignore unhandled keyword arguments, the same config can be used for multiple mechanisms:</p>

<pre class="ruby"><span class="ruby-identifier">password</span>  = <span class="ruby-keyword">nil</span> <span class="ruby-comment"># saved locally, so we don&#39;t ask more than once</span>
<span class="ruby-identifier">accesstok</span> = <span class="ruby-keyword">nil</span> <span class="ruby-comment"># saved locally...</span>
<span class="ruby-identifier">creds</span> = {
  <span class="ruby-value">authcid:</span>      <span class="ruby-identifier">username</span>,
  <span class="ruby-value">password:</span>     <span class="ruby-identifier">proc</span> { <span class="ruby-identifier">password</span>  <span class="ruby-operator">||=</span> <span class="ruby-identifier">ui</span>.<span class="ruby-identifier">prompt_for_password</span> },
  <span class="ruby-value">oauth2_token:</span> <span class="ruby-identifier">proc</span> { <span class="ruby-identifier">accesstok</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">kms</span>.<span class="ruby-identifier">fresh_access_token</span> },
}
<span class="ruby-identifier">capa</span> = <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">capability</span>
<span class="ruby-keyword">if</span>    <span class="ruby-identifier">capa</span>.<span class="ruby-identifier">include?</span> <span class="ruby-string">&quot;AUTH=OAUTHBEARER&quot;</span>
  <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">authenticate</span> <span class="ruby-string">&quot;OAUTHBEARER&quot;</span>,   <span class="ruby-operator">**</span><span class="ruby-identifier">creds</span> <span class="ruby-comment"># authcid, oauth2_token</span>
<span class="ruby-keyword">elsif</span> <span class="ruby-identifier">capa</span>.<span class="ruby-identifier">include?</span> <span class="ruby-string">&quot;AUTH=XOAUTH2&quot;</span>
  <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">authenticate</span> <span class="ruby-string">&quot;XOAUTH2&quot;</span>,       <span class="ruby-operator">**</span><span class="ruby-identifier">creds</span> <span class="ruby-comment"># authcid, oauth2_token</span>
<span class="ruby-keyword">elsif</span> <span class="ruby-identifier">capa</span>.<span class="ruby-identifier">include?</span> <span class="ruby-string">&quot;AUTH=SCRAM-SHA-256&quot;</span>
  <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">authenticate</span> <span class="ruby-string">&quot;SCRAM-SHA-256&quot;</span>, <span class="ruby-operator">**</span><span class="ruby-identifier">creds</span> <span class="ruby-comment"># authcid, password</span>
<span class="ruby-keyword">elsif</span> <span class="ruby-identifier">capa</span>.<span class="ruby-identifier">include?</span> <span class="ruby-string">&quot;AUTH=PLAIN&quot;</span>
  <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">authenticate</span> <span class="ruby-string">&quot;PLAIN&quot;</span>,         <span class="ruby-operator">**</span><span class="ruby-identifier">creds</span> <span class="ruby-comment"># authcid, password</span>
<span class="ruby-keyword">elsif</span> <span class="ruby-identifier">capa</span>.<span class="ruby-identifier">include?</span> <span class="ruby-string">&quot;AUTH=DIGEST-MD5&quot;</span>
  <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">authenticate</span> <span class="ruby-string">&quot;DIGEST-MD5&quot;</span>,    <span class="ruby-operator">**</span><span class="ruby-identifier">creds</span> <span class="ruby-comment"># authcid, password</span>
<span class="ruby-keyword">elsif</span> <span class="ruby-identifier">capa</span>.<span class="ruby-identifier">include?</span> <span class="ruby-string">&quot;LOGINDISABLED&quot;</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-string">&quot;the server has disabled login&quot;</span>
<span class="ruby-keyword">else</span>
  <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">login</span> <span class="ruby-identifier">username</span>, <span class="ruby-identifier">password</span>
<span class="ruby-keyword">end</span>
</pre>

                              <div class="method-source-code" id="authenticate-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1040</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">authenticate</span>(<span class="ruby-identifier">mechanism</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">**</span><span class="ruby-identifier">props</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">cb</span>)
  <span class="ruby-identifier">authenticator</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">authenticator</span>(<span class="ruby-identifier">mechanism</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">**</span><span class="ruby-identifier">props</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">cb</span>)
  <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;AUTHENTICATE&quot;</span>, <span class="ruby-identifier">mechanism</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">resp</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">instance_of?</span>(<span class="ruby-constant">ContinuationRequest</span>)
      <span class="ruby-identifier">data</span> = <span class="ruby-identifier">authenticator</span>.<span class="ruby-identifier">process</span>(<span class="ruby-identifier">resp</span>.<span class="ruby-identifier">data</span>.<span class="ruby-identifier">text</span>.<span class="ruby-identifier">unpack</span>(<span class="ruby-string">&quot;m&quot;</span>)[<span class="ruby-value">0</span>])
      <span class="ruby-identifier">s</span> = [<span class="ruby-identifier">data</span>].<span class="ruby-identifier">pack</span>(<span class="ruby-string">&quot;m0&quot;</span>)
      <span class="ruby-identifier">send_string_data</span>(<span class="ruby-identifier">s</span>)
      <span class="ruby-identifier">put_string</span>(<span class="ruby-constant">CRLF</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-capability" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">capability</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.1.1">CAPABILITY command [IMAP4rev1 §6.1.1]</a> and returns an array of capabilities that the server supports.  Each capability is a string.</p>

<p>See the <a href="http://www.iana.org/assignments/imap4-capabilities">IANA IMAP4 capabilities registry</a> for a list of all standard capabilities, and their reference RFCs.</p>

<blockquote>
<p><strong><em>Note</strong> that Net::IMAP does not currently modify its behaviour according to the capabilities of the server; it is up to the user of the class to ensure that a certain capability is supported by a server before using it.</em></p>
</blockquote>

<p>Capability requirements—other than <code>IMAP4rev1</code>—are listed in the documentation for each command method.</p>

<h5 id="method-i-capability-label-Basic+IMAP4rev1+capabilities">Basic IMAP4rev1 capabilities<span><a href="#method-i-capability-label-Basic+IMAP4rev1+capabilities">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p>All IMAP4rev1 servers must include <code>IMAP4rev1</code> in their capabilities list. All IMAP4rev1 servers must <em>implement</em> the <code>STARTTLS</code>, <code>AUTH=PLAIN</code>, and <code>LOGINDISABLED</code> capabilities, and clients must respect their presence or absence.  See the capabilites requirements on <a href="IMAP.html#method-i-starttls"><code>starttls</code></a>, <a href="IMAP.html#method-i-login"><code>login</code></a>, and <a href="IMAP.html#method-i-authenticate"><code>authenticate</code></a>.</p>

<h5 id="method-i-capability-label-Using+IMAP4rev1+extensions">Using IMAP4rev1 extensions<span><a href="#method-i-capability-label-Using+IMAP4rev1+extensions">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p>IMAP4rev1 servers must not activate incompatible behavior until an explicit client action invokes a capability, e.g. sending a command or command argument specific to that capability.  Extensions with backward compatible behavior, such as response codes or mailbox attributes, may be sent at any time.</p>

<p>Invoking capabilities which are unknown to <a href="IMAP.html"><code>Net::IMAP</code></a> may cause unexpected behavior and errors, for example <a href="IMAP/ResponseParseError.html"><code>ResponseParseError</code></a> is raised when unknown response syntax is received.  Invoking commands or command parameters that are unsupported by the server may raise <a href="IMAP/NoResponseError.html"><code>NoResponseError</code></a>, <a href="IMAP/BadResponseError.html"><code>BadResponseError</code></a>, or cause other unexpected behavior.</p>

<h5 id="method-i-capability-label-Caching+CAPABILITY+responses">Caching <code>CAPABILITY</code> responses<span><a href="#method-i-capability-label-Caching+CAPABILITY+responses">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p>Servers may send their capability list, unsolicited, using the <code>CAPABILITY</code> response code or an untagged <code>CAPABILITY</code> response.  These responses can be retrieved and cached using <a href="IMAP.html#attribute-i-responses"><code>responses</code></a> or <a href="IMAP.html#method-i-add_response_handler"><code>add_response_handler</code></a>.</p>

<p>But cached capabilities <em>must</em> be discarded after <a href="IMAP.html#method-i-starttls"><code>starttls</code></a>, <a href="IMAP.html#method-i-login"><code>login</code></a>, or <a href="IMAP.html#method-i-authenticate"><code>authenticate</code></a>.  The OK <a href="IMAP/TaggedResponse.html"><code>TaggedResponse</code></a> to <a href="IMAP.html#method-i-login"><code>login</code></a> and <a href="IMAP.html#method-i-authenticate"><code>authenticate</code></a> may include <code>CAPABILITY</code> response code data, but the <a href="IMAP/TaggedResponse.html"><code>TaggedResponse</code></a> for <a href="IMAP.html#method-i-starttls"><code>starttls</code></a> is sent clear-text and cannot be trusted.</p>

                              <div class="method-source-code" id="capability-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 849</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">capability</span>
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;CAPABILITY&quot;</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-ivar">@responses</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&quot;CAPABILITY&quot;</span>)[<span class="ruby-value">-1</span>]
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-check" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">check</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.4.1">CHECK command [IMAP4rev1 §6.4.1]</a> to request a checkpoint of the currently selected mailbox.  This performs implementation-specific housekeeping; for instance, reconciling the mailbox’s in-memory and on-disk state.</p>

<p>Related: <a href="IMAP.html#method-i-idle"><code>idle</code></a>, <a href="IMAP.html#method-i-noop"><code>noop</code></a></p>

                              <div class="method-source-code" id="check-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1503</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">check</span>
  <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;CHECK&quot;</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-close" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">close</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.4.2">CLOSE command [IMAP4rev1 §6.4.2]</a> to close the currently selected mailbox.  The CLOSE command permanently removes from the mailbox all messages that have the <code>\Deleted</code> flag set.</p>

<p>Related: <a href="IMAP.html#method-i-unselect"><code>unselect</code></a></p>

                              <div class="method-source-code" id="close-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1513</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">close</span>
  <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;CLOSE&quot;</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-copy" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">copy</span><span
                                class="method-args">(set, mailbox)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.4.7">COPY command [IMAP4rev1 §6.4.7]</a> to copy the specified message(s) to the end of the specified destination <code>mailbox</code>. The <code>set</code> parameter is a number, an array of numbers, or a Range object.  The number is a message sequence number.</p>

<p>Related: <a href="IMAP.html#method-i-uid_copy"><code>uid_copy</code></a></p>

<h5 id="method-i-copy-label-Capabilities">Capabilities<span><a href="#method-i-copy-label-Capabilities">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p>If <code>UIDPLUS</code> [<a href="https://www.rfc-editor.org/rfc/rfc4315.html">RFC4315</a>] is supported, the server’s response should include a <code>COPYUID</code> response code with <a href="IMAP/UIDPlusData.html"><code>UIDPlusData</code></a>.  This will report the UIDVALIDITY of the destination mailbox, the UID set of the source messages, and the assigned UID set of the moved messages.</p>

                              <div class="method-source-code" id="copy-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1749</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">copy</span>(<span class="ruby-identifier">set</span>, <span class="ruby-identifier">mailbox</span>)
  <span class="ruby-identifier">copy_internal</span>(<span class="ruby-string">&quot;COPY&quot;</span>, <span class="ruby-identifier">set</span>, <span class="ruby-identifier">mailbox</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-create" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">create</span><span
                                class="method-args">(mailbox)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.3.3">CREATE command [IMAP4rev1 §6.3.3]</a> to create a new <code>mailbox</code>.</p>

<p>A <a href="IMAP/NoResponseError.html"><code>Net::IMAP::NoResponseError</code></a> is raised if a mailbox with that name cannot be created.</p>

<p>Related: <a href="IMAP.html#method-i-rename"><code>rename</code></a>, <a href="IMAP.html#method-i-delete"><code>delete</code></a></p>

                              <div class="method-source-code" id="create-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1129</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">create</span>(<span class="ruby-identifier">mailbox</span>)
  <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;CREATE&quot;</span>, <span class="ruby-identifier">mailbox</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-delete" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">delete</span><span
                                class="method-args">(mailbox)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.3.4">DELETE command [IMAP4rev1 §6.3.4]</a> to remove the <code>mailbox</code>.</p>

<p>A <a href="IMAP/NoResponseError.html"><code>Net::IMAP::NoResponseError</code></a> is raised if a mailbox with that name cannot be deleted, either because it does not exist or because the client does not have permission to delete it.</p>

<p>Related: <a href="IMAP.html#method-i-create"><code>create</code></a>, <a href="IMAP.html#method-i-rename"><code>rename</code></a></p>

                              <div class="method-source-code" id="delete-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1141</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">delete</span>(<span class="ruby-identifier">mailbox</span>)
  <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;DELETE&quot;</span>, <span class="ruby-identifier">mailbox</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-disconnect" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">disconnect</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Disconnects from the server.</p>

<p>Related: <a href="IMAP.html#method-i-logout"><code>logout</code></a></p>

                              <div class="method-source-code" id="disconnect-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 768</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">disconnect</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">disconnected?</span>
  <span class="ruby-keyword">begin</span>
    <span class="ruby-keyword">begin</span>
      <span class="ruby-comment"># try to call SSL::SSLSocket#io.</span>
      <span class="ruby-ivar">@sock</span>.<span class="ruby-identifier">io</span>.<span class="ruby-identifier">shutdown</span>
    <span class="ruby-keyword">rescue</span> <span class="ruby-constant">NoMethodError</span>
      <span class="ruby-comment"># @sock is not an SSL::SSLSocket.</span>
      <span class="ruby-ivar">@sock</span>.<span class="ruby-identifier">shutdown</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOTCONN</span>
    <span class="ruby-comment"># ignore `Errno::ENOTCONN: Socket is not connected&#39; on some platforms.</span>
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Exception</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">e</span>
    <span class="ruby-ivar">@receiver_thread</span>.<span class="ruby-identifier">raise</span>(<span class="ruby-identifier">e</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-ivar">@receiver_thread</span>.<span class="ruby-identifier">join</span>
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-ivar">@sock</span>.<span class="ruby-identifier">close</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">e</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-disconnected-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">disconnected?</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns true if disconnected from the server.</p>

<p>Related: <a href="IMAP.html#method-i-logout"><code>logout</code></a>, <a href="IMAP.html#method-i-disconnect"><code>disconnect</code></a></p>

                              <div class="method-source-code" id="disconnected-3F-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 793</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">disconnected?</span>
  <span class="ruby-keyword">return</span> <span class="ruby-ivar">@sock</span>.<span class="ruby-identifier">closed?</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-examine" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">examine</span><span
                                class="method-args">(mailbox)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.3.2">EXAMINE command [IMAP4rev1 §6.3.2]</a> to select a <code>mailbox</code> so that messages in the <code>mailbox</code> can be accessed. Behaves the same as <a href="IMAP.html#method-i-select"><code>select</code></a>, except that the selected <code>mailbox</code> is identified as read-only.</p>

<p>A <a href="IMAP/NoResponseError.html"><code>Net::IMAP::NoResponseError</code></a> is raised if the mailbox does not exist or is for some reason non-examinable.</p>

<p>Related: <a href="IMAP.html#method-i-select"><code>select</code></a></p>

                              <div class="method-source-code" id="examine-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1115</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">examine</span>(<span class="ruby-identifier">mailbox</span>)
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-ivar">@responses</span>.<span class="ruby-identifier">clear</span>
    <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;EXAMINE&quot;</span>, <span class="ruby-identifier">mailbox</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-expunge" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">expunge</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends an <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.4.3">EXPUNGE command [IMAP4rev1 §6.4.3]</a> Sends a EXPUNGE command to permanently remove from the currently selected mailbox all messages that have the Deleted flag set.</p>

<p>Related: <a href="IMAP.html#method-i-uid_expunge"><code>uid_expunge</code></a></p>

                              <div class="method-source-code" id="expunge-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1538</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">expunge</span>
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;EXPUNGE&quot;</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-ivar">@responses</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&quot;EXPUNGE&quot;</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-fetch" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">fetch</span><span
                                class="method-args">(set, attr, mod = nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.4.5">FETCH command [IMAP4rev1 §6.4.5]</a> to retrieve data associated with a message in the mailbox.</p>

<p>The <code>set</code> parameter is a number or a range between two numbers, or an array of those.  The number is a message sequence number, where -1 represents a ‘*’ for use in range notation like 100..-1 being interpreted as ‘100:*’.  Beware that the <code>exclude_end?</code> property of a Range object is ignored, and the contents of a range are independent of the order of the range endpoints as per the protocol specification, so 1…5, 5..1 and 5…1 are all equivalent to 1..5.</p>

<p><code>attr</code> is a list of attributes to fetch; see the documentation for <a href="IMAP/FetchData.html"><code>FetchData</code></a> for a list of valid attributes.</p>

<p>The return value is an array of <a href="IMAP/FetchData.html"><code>FetchData</code></a> or nil (instead of an empty array) if there is no matching message.</p>

<p>Related: <a href="IMAP.html#method-i-uid_search"><code>uid_search</code></a>, <a href="IMAP/FetchData.html"><code>FetchData</code></a></p>

<h5 id="method-i-fetch-label-For+example-3A">For example:<span><a href="#method-i-fetch-label-For+example-3A">&para;</a> <a href="#top">&uarr;</a></span></h5>

<pre class="ruby"><span class="ruby-identifier">p</span> <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">6</span><span class="ruby-operator">..</span><span class="ruby-value">8</span>, <span class="ruby-string">&quot;UID&quot;</span>)
<span class="ruby-comment">#=&gt; [#&lt;Net::IMAP::FetchData seqno=6, attr={&quot;UID&quot;=&gt;98}&gt;, \\</span>
     <span class="ruby-comment">#&lt;Net::IMAP::FetchData seqno=7, attr={&quot;UID&quot;=&gt;99}&gt;, \\</span>
     <span class="ruby-comment">#&lt;Net::IMAP::FetchData seqno=8, attr={&quot;UID&quot;=&gt;100}&gt;]</span>
<span class="ruby-identifier">p</span> <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">6</span>, <span class="ruby-string">&quot;BODY[HEADER.FIELDS (SUBJECT)]&quot;</span>)
<span class="ruby-comment">#=&gt; [#&lt;Net::IMAP::FetchData seqno=6, attr={&quot;BODY[HEADER.FIELDS (SUBJECT)]&quot;=&gt;&quot;Subject: test\r\n\r\n&quot;}&gt;]</span>
<span class="ruby-identifier">data</span> = <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">uid_fetch</span>(<span class="ruby-value">98</span>, [<span class="ruby-string">&quot;RFC822.SIZE&quot;</span>, <span class="ruby-string">&quot;INTERNALDATE&quot;</span>])[<span class="ruby-value">0</span>]
<span class="ruby-identifier">p</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">seqno</span>
<span class="ruby-comment">#=&gt; 6</span>
<span class="ruby-identifier">p</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">attr</span>[<span class="ruby-string">&quot;RFC822.SIZE&quot;</span>]
<span class="ruby-comment">#=&gt; 611</span>
<span class="ruby-identifier">p</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">attr</span>[<span class="ruby-string">&quot;INTERNALDATE&quot;</span>]
<span class="ruby-comment">#=&gt; &quot;12-Oct-2000 22:40:59 +0900&quot;</span>
<span class="ruby-identifier">p</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">attr</span>[<span class="ruby-string">&quot;UID&quot;</span>]
<span class="ruby-comment">#=&gt; 98</span>
</pre>

                              <div class="method-source-code" id="fetch-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1681</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">fetch</span>(<span class="ruby-identifier">set</span>, <span class="ruby-identifier">attr</span>, <span class="ruby-identifier">mod</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">fetch_internal</span>(<span class="ruby-string">&quot;FETCH&quot;</span>, <span class="ruby-identifier">set</span>, <span class="ruby-identifier">attr</span>, <span class="ruby-identifier">mod</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-getacl" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">getacl</span><span
                                class="method-args">(mailbox)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc4314#section-3.3">GETACL command [RFC4314 §3.3]</a> along with a specified <code>mailbox</code>.  If this mailbox exists, an array containing objects of <a href="IMAP/MailboxACLItem.html"><code>MailboxACLItem</code></a> will be returned.</p>

<p>Related: <a href="IMAP.html#method-i-setacl"><code>setacl</code></a>, <a href="IMAP/MailboxACLItem.html"><code>MailboxACLItem</code></a></p>

<h5 id="method-i-getacl-label-Capabilities">Capabilities<span><a href="#method-i-getacl-label-Capabilities">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p>The server’s capabilities must include <code>ACL</code> [<a href="https://tools.ietf.org/html/rfc4314">RFC4314</a>].</p>

                              <div class="method-source-code" id="getacl-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1410</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">getacl</span>(<span class="ruby-identifier">mailbox</span>)
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;GETACL&quot;</span>, <span class="ruby-identifier">mailbox</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-ivar">@responses</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&quot;ACL&quot;</span>)[<span class="ruby-value">-1</span>]
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-getquota" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">getquota</span><span
                                class="method-args">(mailbox)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc2087#section-4.2">GETQUOTA command [RFC2087 §4.2]</a> along with specified <code>mailbox</code>.  If this mailbox exists, then an array containing a <a href="IMAP/MailboxQuota.html"><code>MailboxQuota</code></a> object is returned.  This command is generally only available to server admin.</p>

<p>Related: <a href="IMAP.html#method-i-getquotaroot"><code>getquotaroot</code></a>, <a href="IMAP.html#method-i-setquota"><code>setquota</code></a>, <a href="IMAP/MailboxQuota.html"><code>MailboxQuota</code></a></p>

<h5 id="method-i-getquota-label-Capabilities">Capabilities<span><a href="#method-i-getquota-label-Capabilities">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p>The server’s capabilities must include <code>QUOTA</code> [<a href="https://tools.ietf.org/html/rfc2087">RFC2087</a>].</p>

                              <div class="method-source-code" id="getquota-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1354</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">getquota</span>(<span class="ruby-identifier">mailbox</span>)
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;GETQUOTA&quot;</span>, <span class="ruby-identifier">mailbox</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-ivar">@responses</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&quot;QUOTA&quot;</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-getquotaroot" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">getquotaroot</span><span
                                class="method-args">(mailbox)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc2087#section-4.3">GETQUOTAROOT command [RFC2087 §4.3]</a> along with the specified <code>mailbox</code>.  This command is generally available to both admin and user.  If this mailbox exists, it returns an array containing objects of type <a href="IMAP/MailboxQuotaRoot.html"><code>MailboxQuotaRoot</code></a> and <a href="IMAP/MailboxQuota.html"><code>MailboxQuota</code></a>.</p>

<p>Related: <a href="IMAP.html#method-i-getquota"><code>getquota</code></a>, <a href="IMAP.html#method-i-setquota"><code>setquota</code></a>, <a href="IMAP/MailboxQuotaRoot.html"><code>MailboxQuotaRoot</code></a>, <a href="IMAP/MailboxQuota.html"><code>MailboxQuota</code></a></p>

<h5 id="method-i-getquotaroot-label-Capabilities">Capabilities<span><a href="#method-i-getquotaroot-label-Capabilities">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p>The server’s capabilities must include <code>QUOTA</code> [<a href="https://tools.ietf.org/html/rfc2087">RFC2087</a>].</p>

                              <div class="method-source-code" id="getquotaroot-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1333</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">getquotaroot</span>(<span class="ruby-identifier">mailbox</span>)
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;GETQUOTAROOT&quot;</span>, <span class="ruby-identifier">mailbox</span>)
    <span class="ruby-identifier">result</span> = []
    <span class="ruby-identifier">result</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-ivar">@responses</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&quot;QUOTAROOT&quot;</span>))
    <span class="ruby-identifier">result</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-ivar">@responses</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&quot;QUOTA&quot;</span>))
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">result</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-id" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">id</span><span
                                class="method-args">(client_id=nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends an <a href="https://www.rfc-editor.org/rfc/rfc2971#section-3.1">ID command [RFC2971 §3.1]</a> and returns a hash of the server’s response, or nil if the server does not identify itself.</p>

<p>Note that the user should first check if the server supports the ID capability. For example:</p>

<pre class="ruby"><span class="ruby-identifier">capabilities</span> = <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">capability</span>
<span class="ruby-keyword">if</span> <span class="ruby-identifier">capabilities</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&quot;ID&quot;</span>)
  <span class="ruby-identifier">id</span> = <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">id</span>(
    <span class="ruby-value">name:</span> <span class="ruby-string">&quot;my IMAP client (ruby)&quot;</span>,
    <span class="ruby-value">version:</span> <span class="ruby-constant">MyIMAP</span><span class="ruby-operator">::</span><span class="ruby-constant">VERSION</span>,
    <span class="ruby-value">&quot;support-url&quot;:</span> <span class="ruby-string">&quot;mailto:bugs@example.com&quot;</span>,
    <span class="ruby-value">os:</span> <span class="ruby-constant">RbConfig</span><span class="ruby-operator">::</span><span class="ruby-constant">CONFIG</span>[<span class="ruby-string">&quot;host_os&quot;</span>],
  )
<span class="ruby-keyword">end</span>
</pre>

<p>See [<a href="https://tools.ietf.org/html/rfc2971">ID</a>] for field definitions.</p>

<h5 id="method-i-id-label-Capabilities">Capabilities<span><a href="#method-i-id-label-Capabilities">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p>The server’s capabilities must include <code>ID</code></p>
<dl class="rdoc-list label-list"><dt><a href="https://tools.ietf.org/html/rfc2971">RFC2971</a>
<dd></dd></dl>

                              <div class="method-source-code" id="id-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 879</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">id</span>(<span class="ruby-identifier">client_id</span>=<span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;ID&quot;</span>, <span class="ruby-constant">ClientID</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">client_id</span>))
    <span class="ruby-ivar">@responses</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&quot;ID&quot;</span>)&amp;.<span class="ruby-identifier">last</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-idle" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">idle</span><span
                                class="method-args">(timeout = nil, &amp;response_handler)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends an <a href="https://www.rfc-editor.org/rfc/rfc6851#section-3">IDLE command [RFC2177 §3]</a> <a href="https://www.rfc-editor.org/rfc/rfc9051#section-6.3.13">[IMAP4rev2 §6.3.13]</a> that waits for notifications of new or expunged messages.  Yields responses from the server during the IDLE.</p>

<p>Use <a href="IMAP.html#method-i-idle_done"><code>idle_done</code></a> to leave IDLE.</p>

<p>If <code>timeout</code> is given, this method returns after <code>timeout</code> seconds passed. <code>timeout</code> can be used for keep-alive.  For example, the following code checks the connection for each 60 seconds.</p>

<pre>loop do
  imap.idle(60) do |res|
    ...
  end
end</pre>

<p>Related: <a href="IMAP.html#method-i-idle_done"><code>idle_done</code></a>, <a href="IMAP.html#method-i-noop"><code>noop</code></a>, <a href="IMAP.html#method-i-check"><code>check</code></a></p>

<h5 id="method-i-idle-label-Capabilities">Capabilities<span><a href="#method-i-idle-label-Capabilities">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p>The server’s capabilities must include <code>IDLE</code> [<a href="https://tools.ietf.org/html/rfc2177">RFC2177</a>].</p>

                              <div class="method-source-code" id="idle-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1910</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">idle</span>(<span class="ruby-identifier">timeout</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">response_handler</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">LocalJumpError</span>, <span class="ruby-string">&quot;no block given&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">response_handler</span>

  <span class="ruby-identifier">response</span> = <span class="ruby-keyword">nil</span>

  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">tag</span> = <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span>[<span class="ruby-value">:net_imap_tag</span>] = <span class="ruby-identifier">generate_tag</span>
    <span class="ruby-identifier">put_string</span>(<span class="ruby-node">&quot;#{tag} IDLE#{CRLF}&quot;</span>)

    <span class="ruby-keyword">begin</span>
      <span class="ruby-identifier">add_response_handler</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">response_handler</span>)
      <span class="ruby-ivar">@idle_done_cond</span> = <span class="ruby-identifier">new_cond</span>
      <span class="ruby-ivar">@idle_done_cond</span>.<span class="ruby-identifier">wait</span>(<span class="ruby-identifier">timeout</span>)
      <span class="ruby-ivar">@idle_done_cond</span> = <span class="ruby-keyword">nil</span>
      <span class="ruby-keyword">if</span> <span class="ruby-ivar">@receiver_thread_terminating</span>
        <span class="ruby-identifier">raise</span> <span class="ruby-ivar">@exception</span> <span class="ruby-operator">||</span> <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">IMAP</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;connection closed&quot;</span>)
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">ensure</span>
      <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@receiver_thread_terminating</span>
        <span class="ruby-identifier">remove_response_handler</span>(<span class="ruby-identifier">response_handler</span>)
        <span class="ruby-identifier">put_string</span>(<span class="ruby-node">&quot;DONE#{CRLF}&quot;</span>)
        <span class="ruby-identifier">response</span> = <span class="ruby-identifier">get_tagged_response</span>(<span class="ruby-identifier">tag</span>, <span class="ruby-string">&quot;IDLE&quot;</span>, <span class="ruby-ivar">@idle_response_timeout</span>)
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">return</span> <span class="ruby-identifier">response</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-idle_done" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">idle_done</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Leaves IDLE.</p>

<p>Related: <a href="IMAP.html#method-i-idle"><code>idle</code></a></p>

                              <div class="method-source-code" id="idle_done-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1942</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">idle_done</span>
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-keyword">if</span> <span class="ruby-ivar">@idle_done_cond</span>.<span class="ruby-identifier">nil?</span>
      <span class="ruby-identifier">raise</span> <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">IMAP</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span>, <span class="ruby-string">&quot;not during IDLE&quot;</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-ivar">@idle_done_cond</span>.<span class="ruby-identifier">signal</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-list" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">list</span><span
                                class="method-args">(refname, mailbox)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.3.8">LIST command [IMAP4rev1 §6.3.8]</a> and returns a subset of names from the complete set of all names available to the client.  <code>refname</code> provides a context (for instance, a base directory in a directory-based mailbox hierarchy).  <code>mailbox</code> specifies a mailbox or (via wildcards) mailboxes under that context.  Two wildcards may be used in <code>mailbox</code>: ‘*’, which matches all characters <strong>including</strong> the hierarchy delimiter (for instance, ‘/’ on a UNIX-hosted directory-based mailbox hierarchy); and ‘%’, which matches all characters <strong>except</strong> the hierarchy delimiter.</p>

<p>If <code>refname</code> is empty, <code>mailbox</code> is used directly to determine which mailboxes to match.  If <code>mailbox</code> is empty, the root name of <code>refname</code> and the hierarchy delimiter are returned.</p>

<p>The return value is an array of <a href="IMAP/MailboxList.html"><code>MailboxList</code></a>.</p>

<p>Related: <a href="IMAP.html#method-i-lsub"><code>lsub</code></a>, <a href="IMAP/MailboxList.html"><code>MailboxList</code></a></p>

<h5 id="method-i-list-label-For+example-3A">For example:<span><a href="#method-i-list-label-For+example-3A">&para;</a> <a href="#top">&uarr;</a></span></h5>

<pre class="ruby"><span class="ruby-identifier">imap</span>.<span class="ruby-identifier">create</span>(<span class="ruby-string">&quot;foo/bar&quot;</span>)
<span class="ruby-identifier">imap</span>.<span class="ruby-identifier">create</span>(<span class="ruby-string">&quot;foo/baz&quot;</span>)
<span class="ruby-identifier">p</span> <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">list</span>(<span class="ruby-string">&quot;&quot;</span>, <span class="ruby-string">&quot;foo/%&quot;</span>)
<span class="ruby-comment">#=&gt; [#&lt;Net::IMAP::MailboxList attr=[:Noselect], delim=&quot;/&quot;, name=&quot;foo/&quot;&gt;, \\</span>
     <span class="ruby-comment">#&lt;Net::IMAP::MailboxList attr=[:Noinferiors, :Marked], delim=&quot;/&quot;, name=&quot;foo/bar&quot;&gt;, \\</span>
     <span class="ruby-comment">#&lt;Net::IMAP::MailboxList attr=[:Noinferiors], delim=&quot;/&quot;, name=&quot;foo/baz&quot;&gt;]</span>
</pre>

                              <div class="method-source-code" id="list-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1213</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">list</span>(<span class="ruby-identifier">refname</span>, <span class="ruby-identifier">mailbox</span>)
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;LIST&quot;</span>, <span class="ruby-identifier">refname</span>, <span class="ruby-identifier">mailbox</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-ivar">@responses</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&quot;LIST&quot;</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-login" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">login</span><span
                                class="method-args">(user, password)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.2.3">LOGIN command [IMAP4rev1 §6.2.3]</a> to identify the client and carries the plaintext <code>password</code> authenticating this <code>user</code>.  If successful, the connection enters the “<em>authenticated</em>” state.</p>

<p>Using <a href="IMAP.html#method-i-authenticate"><code>authenticate</code></a> is generally preferred over <a href="IMAP.html#method-i-login"><code>login</code></a>.  The LOGIN command is not the same as <a href="IMAP.html#method-i-authenticate"><code>authenticate</code></a> with the “LOGIN” <code>mechanism</code>.</p>

<p>A <a href="IMAP/NoResponseError.html"><code>Net::IMAP::NoResponseError</code></a> is raised if authentication fails.</p>

<p>Related: <a href="IMAP.html#method-i-authenticate"><code>authenticate</code></a>, <a href="IMAP.html#method-i-starttls"><code>starttls</code></a></p>

<h4 id="method-i-login-label-Capabilities">Capabilities<span><a href="#method-i-login-label-Capabilities">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>Clients MUST NOT call <a href="IMAP.html#method-i-login"><code>login</code></a> if <code>LOGINDISABLED</code> is listed with the capabilities.</p>

<p>Server capabilities may change after <a href="IMAP.html#method-i-starttls"><code>starttls</code></a>, <a href="IMAP.html#method-i-login"><code>login</code></a>, and <a href="IMAP.html#method-i-authenticate"><code>authenticate</code></a>. Cached capabilities <em>must</em> be invalidated after this method completes. The <a href="IMAP/TaggedResponse.html"><code>TaggedResponse</code></a> to <a href="IMAP.html#method-i-login"><code>login</code></a> may include updated capabilities in its <a href="IMAP/ResponseCode.html"><code>ResponseCode</code></a>.</p>

                              <div class="method-source-code" id="login-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1073</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">login</span>(<span class="ruby-identifier">user</span>, <span class="ruby-identifier">password</span>)
  <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;LOGIN&quot;</span>, <span class="ruby-identifier">user</span>, <span class="ruby-identifier">password</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-logout" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">logout</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.1.3">LOGOUT command [IMAP4rev1 §6.1.3]</a> to inform the command to inform the server that the client is done with the connection.</p>

<p>Related: <a href="IMAP.html#method-i-disconnect"><code>disconnect</code></a></p>

                              <div class="method-source-code" id="logout-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 907</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">logout</span>
  <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;LOGOUT&quot;</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-lsub" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">lsub</span><span
                                class="method-args">(refname, mailbox)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.3.9">LSUB command [IMAP4rev1 §6.3.9]</a> and returns a subset of names from the set of names that the user has declared as being “active” or “subscribed.”  <code>refname</code> and <code>mailbox</code> are interpreted as for <a href="IMAP.html#method-i-list"><code>list</code></a>.</p>

<p>The return value is an array of <a href="IMAP/MailboxList.html"><code>MailboxList</code></a> objects.</p>

<p>Related: <a href="IMAP.html#method-i-subscribe"><code>subscribe</code></a>, <a href="IMAP.html#method-i-unsubscribe"><code>unsubscribe</code></a>, <a href="IMAP.html#method-i-list"><code>list</code></a>, <a href="IMAP/MailboxList.html"><code>MailboxList</code></a></p>

                              <div class="method-source-code" id="lsub-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1425</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">lsub</span>(<span class="ruby-identifier">refname</span>, <span class="ruby-identifier">mailbox</span>)
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;LSUB&quot;</span>, <span class="ruby-identifier">refname</span>, <span class="ruby-identifier">mailbox</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-ivar">@responses</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&quot;LSUB&quot;</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-move" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">move</span><span
                                class="method-args">(set, mailbox)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc6851#section-3.1">MOVE command [RFC6851 §3.1]</a> <a href="https://www.rfc-editor.org/rfc/rfc9051#section-6.4.8">[IMAP4rev2 §6.4.8]</a> to move the specified message(s) to the end of the specified destination <code>mailbox</code>. The <code>set</code> parameter is a number, an array of numbers, or a Range object. The number is a message sequence number.</p>

<p>Related: <a href="IMAP.html#method-i-uid_move"><code>uid_move</code></a></p>

<h5 id="method-i-move-label-Capabilities">Capabilities<span><a href="#method-i-move-label-Capabilities">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p>The server’s capabilities must include <code>MOVE</code> [<a href="https://tools.ietf.org/html/rfc6851">RFC6851</a>].</p>

<p>If <code>UIDPLUS</code> [<a href="https://www.rfc-editor.org/rfc/rfc4315.html">RFC4315</a>] is supported, the server’s response should include a <code>COPYUID</code> response code with <a href="IMAP/UIDPlusData.html"><code>UIDPlusData</code></a>.  This will report the UIDVALIDITY of the destination mailbox, the UID set of the source messages, and the assigned UID set of the moved messages.</p>

                              <div class="method-source-code" id="move-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1785</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">move</span>(<span class="ruby-identifier">set</span>, <span class="ruby-identifier">mailbox</span>)
  <span class="ruby-identifier">copy_internal</span>(<span class="ruby-string">&quot;MOVE&quot;</span>, <span class="ruby-identifier">set</span>, <span class="ruby-identifier">mailbox</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-namespace" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">namespace</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc2342#section-5">NAMESPACE command [RFC2342 §5]</a> and returns the namespaces that are available.  The NAMESPACE command allows a client to discover the prefixes of namespaces used by a server for personal mailboxes, other users’ mailboxes, and shared mailboxes.</p>

<p>The return value is a <a href="IMAP/Namespaces.html"><code>Namespaces</code></a> object which has <code>personal</code>, <code>other</code>, and <code>shared</code> fields, each an array of <a href="IMAP/Namespace.html"><code>Namespace</code></a> objects.  These arrays will be empty when the server responds with <code>nil</code>.</p>

<p>Many IMAP servers are configured with the default personal namespaces as <code>(&quot;&quot; &quot;/&quot;)</code>: no prefix and the “<code>/</code>” hierarchy delimiter. In that common case, the naive client may not have any trouble naming mailboxes. But many servers are configured with the default personal namespace as e.g.  <code>(&quot;INBOX.&quot; &quot;.&quot;)</code>, placing all personal folders under INBOX, with “<code>.</code>” as the hierarchy delimiter. If the client does not check for this, but naively assumes it can use the same folder names for all servers, then folder creation (and listing, moving, etc) can lead to errors.</p>

<p>From RFC2342:</p>

<pre>Although typically a server will support only a single Personal
Namespace, and a single Other User&#39;s Namespace, circumstances exist
where there MAY be multiples of these, and a client MUST be prepared
for them.  If a client is configured such that it is required to create
a certain mailbox, there can be circumstances where it is unclear which
Personal Namespaces it should create the mailbox in.  In these
situations a client SHOULD let the user select which namespaces to
create the mailbox in.</pre>

<p>Related: <a href="IMAP.html#method-i-list"><code>list</code></a>, <a href="IMAP/Namespaces.html"><code>Namespaces</code></a>, <a href="IMAP/Namespace.html"><code>Namespace</code></a></p>

<h5 id="method-i-namespace-label-For+example-3A">For example:<span><a href="#method-i-namespace-label-For+example-3A">&para;</a> <a href="#top">&uarr;</a></span></h5>

<pre class="ruby"><span class="ruby-identifier">capabilities</span> = <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">capability</span>
<span class="ruby-keyword">if</span> <span class="ruby-identifier">capabilities</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&quot;NAMESPACE&quot;</span>)
  <span class="ruby-identifier">namespaces</span> = <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">namespace</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">namespace</span> = <span class="ruby-identifier">namespaces</span>.<span class="ruby-identifier">personal</span>.<span class="ruby-identifier">first</span>
    <span class="ruby-identifier">prefix</span> = <span class="ruby-identifier">namespace</span>.<span class="ruby-identifier">prefix</span>  <span class="ruby-comment"># e.g. &quot;&quot; or &quot;INBOX.&quot;</span>
    <span class="ruby-identifier">delim</span>  = <span class="ruby-identifier">namespace</span>.<span class="ruby-identifier">delim</span>   <span class="ruby-comment"># e.g. &quot;/&quot; or &quot;.&quot;</span>
    <span class="ruby-comment"># personal folders should use the prefix and delimiter</span>
    <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">create</span>(<span class="ruby-identifier">prefix</span> <span class="ruby-operator">+</span> <span class="ruby-string">&quot;foo&quot;</span>)
    <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">create</span>(<span class="ruby-identifier">prefix</span> <span class="ruby-operator">+</span> <span class="ruby-string">&quot;bar&quot;</span>)
    <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">create</span>(<span class="ruby-identifier">prefix</span> <span class="ruby-operator">+</span> <span class="ruby-node">%w[path to my folder]</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">delim</span>))
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
</pre>

<h5 id="method-i-namespace-label-Capabilities">Capabilities<span><a href="#method-i-namespace-label-Capabilities">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p>The server’s capabilities must include <code>NAMESPACE</code> [<a href="https://tools.ietf.org/html/rfc2342">RFC2342</a>].</p>

                              <div class="method-source-code" id="namespace-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1271</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">namespace</span>
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;NAMESPACE&quot;</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-ivar">@responses</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&quot;NAMESPACE&quot;</span>)[<span class="ruby-value">-1</span>]
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-noop" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">noop</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.1.2">NOOP command [IMAP4rev1 §6.1.2]</a> to the server.</p>

<p>This allows the server to send unsolicited untagged EXPUNGE <a href="IMAP.html#attribute-i-responses"><code>responses</code></a>, but does not execute any client request.  IMAP servers are permitted to send unsolicited untagged responses at any time, except for ‘EXPUNGE`.</p>
<ul><li>
<p><code>EXPUNGE</code> can only be sent while a command is in progress.</p>
</li><li>
<p><code>EXPUNGE</code> must <em>not</em> be sent during <a href="IMAP.html#method-i-fetch"><code>fetch</code></a>, <a href="IMAP.html#method-i-store"><code>store</code></a>, or <a href="IMAP.html#method-i-search"><code>search</code></a>.</p>
</li><li>
<p><code>EXPUNGE</code> may be sent during <a href="IMAP.html#method-i-uid_fetch"><code>uid_fetch</code></a>, <a href="IMAP.html#method-i-uid_store"><code>uid_store</code></a>, or <a href="IMAP.html#method-i-uid_search"><code>uid_search</code></a>.</p>
</li></ul>

<p>Related: <a href="IMAP.html#method-i-idle"><code>idle</code></a>, <a href="IMAP.html#method-i-check"><code>check</code></a></p>

                              <div class="method-source-code" id="noop-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 898</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">noop</span>
  <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;NOOP&quot;</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-remove_response_handler" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">remove_response_handler</span><span
                                class="method-args">(handler)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Removes the response handler.</p>

                              <div class="method-source-code" id="remove_response_handler-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1969</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">remove_response_handler</span>(<span class="ruby-identifier">handler</span>)
  <span class="ruby-ivar">@response_handlers</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">handler</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-rename" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">rename</span><span
                                class="method-args">(mailbox, newname)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.3.5">RENAME command [IMAP4rev1 §6.3.5]</a> to change the name of the <code>mailbox</code> to <code>newname</code>.</p>

<p>A <a href="IMAP/NoResponseError.html"><code>Net::IMAP::NoResponseError</code></a> is raised if a mailbox with the name <code>mailbox</code> cannot be renamed to <code>newname</code> for whatever reason; for instance, because <code>mailbox</code> does not exist, or because there is already a mailbox with the name <code>newname</code>.</p>

<p>Related: <a href="IMAP.html#method-i-create"><code>create</code></a>, <a href="IMAP.html#method-i-delete"><code>delete</code></a></p>

                              <div class="method-source-code" id="rename-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1154</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">rename</span>(<span class="ruby-identifier">mailbox</span>, <span class="ruby-identifier">newname</span>)
  <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;RENAME&quot;</span>, <span class="ruby-identifier">mailbox</span>, <span class="ruby-identifier">newname</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-search" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">search</span><span
                                class="method-args">(keys, charset = nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.4.4">SEARCH command [IMAP4rev1 §6.4.4]</a> to search the mailbox for messages that match the given searching criteria, and returns message sequence numbers.  <code>keys</code> can either be a string holding the entire search string, or a single-dimension array of search keywords and arguments.</p>

<p>Related: <a href="IMAP.html#method-i-uid_search"><code>uid_search</code></a></p>

<h5 id="method-i-search-label-Search+criteria">Search criteria<span><a href="#method-i-search-label-Search+criteria">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p>For a full list of search criteria, see [<a href="https://www.rfc-editor.org/rfc/rfc3501.html#section-6.4.4">IMAP4rev1 §6.4.4</a>], or  [<a href="https://www.rfc-editor.org/rfc/rfc9051.html#section-6.4.4">IMAP4rev2 §6.4.4</a>], in addition to documentation for any [<a href="https://www.iana.org/assignments/imap-capabilities/imap-capabilities.xhtml">CAPABILITIES</a>] reported by <a href="IMAP.html#method-i-capability"><code>capability</code></a> which may define additional search filters, e.g: <code>CONDSTORE</code>, <code>WITHIN</code>, <code>FILTERS</code>, <code>SEARCH=FUZZY</code>, <code>OBJECTID</code>, or <code>SAVEDATE</code>.  The following are some common search criteria:</p>
<dl class="rdoc-list note-list"><dt>&lt;message set&gt;
<dd>
<p>a set of message sequence numbers.  “<code>,</code>” indicates an interval, “<code>:</code>” indicates a range.  For instance, “<code>2,10:12,15</code>” means “<code>2,10,11,12,15</code>”.</p>
</dd><dt>BEFORE &lt;date&gt;
<dd>
<p>messages with an internal date strictly before <strong>&lt;date&gt;</strong>.  The date argument has a format similar to <code>8-Aug-2002</code>, and can be formatted using <a href="IMAP.html#method-c-format_date"><code>Net::IMAP.format_date</code></a>.</p>
</dd><dt>BODY &lt;string&gt;
<dd>
<p>messages that contain &lt;string&gt; within their body.</p>
</dd><dt>CC &lt;string&gt;
<dd>
<p>messages containing &lt;string&gt; in their CC field.</p>
</dd><dt>FROM &lt;string&gt;
<dd>
<p>messages that contain &lt;string&gt; in their FROM field.</p>
</dd><dt>NEW
<dd>
<p>messages with the Recent, but not the Seen, flag set.</p>
</dd><dt>NOT &lt;search-key&gt;
<dd>
<p>negate the following search key.</p>
</dd><dt>OR &lt;search-key&gt; &lt;search-key&gt;
<dd>
<p>“or” two search keys together.</p>
</dd><dt>ON &lt;date&gt;
<dd>
<p>messages with an internal date exactly equal to &lt;date&gt;, which has a format similar to 8-Aug-2002.</p>
</dd><dt>SINCE &lt;date&gt;
<dd>
<p>messages with an internal date on or after &lt;date&gt;.</p>
</dd><dt>SUBJECT &lt;string&gt;
<dd>
<p>messages with &lt;string&gt; in their subject.</p>
</dd><dt>TO &lt;string&gt;
<dd>
<p>messages with &lt;string&gt; in their TO field.</p>
</dd></dl>

<h5 id="method-i-search-label-For+example-3A">For example:<span><a href="#method-i-search-label-For+example-3A">&para;</a> <a href="#top">&uarr;</a></span></h5>

<pre class="ruby"><span class="ruby-identifier">p</span> <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">search</span>([<span class="ruby-string">&quot;SUBJECT&quot;</span>, <span class="ruby-string">&quot;hello&quot;</span>, <span class="ruby-string">&quot;NOT&quot;</span>, <span class="ruby-string">&quot;NEW&quot;</span>])
<span class="ruby-comment">#=&gt; [1, 6, 7, 8]</span>
</pre>

                              <div class="method-source-code" id="search-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1631</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">search</span>(<span class="ruby-identifier">keys</span>, <span class="ruby-identifier">charset</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">search_internal</span>(<span class="ruby-string">&quot;SEARCH&quot;</span>, <span class="ruby-identifier">keys</span>, <span class="ruby-identifier">charset</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-select" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">select</span><span
                                class="method-args">(mailbox)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.3.1">SELECT command [IMAP4rev1 §6.3.1]</a> to select a <code>mailbox</code> so that messages in the <code>mailbox</code> can be accessed.</p>

<p>After you have selected a mailbox, you may retrieve the number of items in that mailbox from <code>imap.responses[&quot;EXISTS&quot;][-1]</code>, and the number of recent messages from <code>imap.responses[&quot;RECENT&quot;][-1]</code>.  Note that these values can change if new messages arrive during a session or when existing messages are expunged; see <a href="IMAP.html#method-i-add_response_handler"><code>add_response_handler</code></a> for a way to detect these events.</p>

<p>A <a href="IMAP/NoResponseError.html"><code>Net::IMAP::NoResponseError</code></a> is raised if the mailbox does not exist or is for some reason non-selectable.</p>

<p>Related: <a href="IMAP.html#method-i-examine"><code>examine</code></a></p>

<h5 id="method-i-select-label-Capabilities">Capabilities<span><a href="#method-i-select-label-Capabilities">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p>If [<a href="https://www.rfc-editor.org/rfc/rfc4315.html">UIDPLUS</a>] is supported, the server may return an untagged “NO” response with a “UIDNOTSTICKY” response code indicating that the mailstore does not support persistent UIDs:</p>

<pre class="ruby"><span class="ruby-ivar">@responses</span>[<span class="ruby-string">&quot;NO&quot;</span>].<span class="ruby-identifier">last</span>.<span class="ruby-identifier">code</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-string">&quot;UIDNOTSTICKY&quot;</span>
</pre>

                              <div class="method-source-code" id="select-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1099</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">select</span>(<span class="ruby-identifier">mailbox</span>)
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-ivar">@responses</span>.<span class="ruby-identifier">clear</span>
    <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;SELECT&quot;</span>, <span class="ruby-identifier">mailbox</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-setacl" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">setacl</span><span
                                class="method-args">(mailbox, user, rights)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc4314#section-3.1">SETACL command [RFC4314 §3.1]</a> along with <code>mailbox</code>, <code>user</code> and the <code>rights</code> that user is to have on that mailbox.  If <code>rights</code> is nil, then that user will be stripped of any rights to that mailbox.</p>

<p>Related: <a href="IMAP.html#method-i-getacl"><code>getacl</code></a></p>

<h5 id="method-i-setacl-label-Capabilities">Capabilities<span><a href="#method-i-setacl-label-Capabilities">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p>The server’s capabilities must include <code>ACL</code> [<a href="https://tools.ietf.org/html/rfc4314">RFC4314</a>].</p>

                              <div class="method-source-code" id="setacl-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1392</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">setacl</span>(<span class="ruby-identifier">mailbox</span>, <span class="ruby-identifier">user</span>, <span class="ruby-identifier">rights</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">rights</span>.<span class="ruby-identifier">nil?</span>
    <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;SETACL&quot;</span>, <span class="ruby-identifier">mailbox</span>, <span class="ruby-identifier">user</span>, <span class="ruby-string">&quot;&quot;</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;SETACL&quot;</span>, <span class="ruby-identifier">mailbox</span>, <span class="ruby-identifier">user</span>, <span class="ruby-identifier">rights</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-setquota" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">setquota</span><span
                                class="method-args">(mailbox, quota)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc2087#section-4.1">SETQUOTA command [RFC2087 §4.1]</a> along with the specified <code>mailbox</code> and <code>quota</code>.  If <code>quota</code> is nil, then <code>quota</code> will be unset for that mailbox.  Typically one needs to be logged in as a server admin for this to work.</p>

<p>Related: <a href="IMAP.html#method-i-getquota"><code>getquota</code></a>, <a href="IMAP.html#method-i-getquotaroot"><code>getquotaroot</code></a></p>

<h5 id="method-i-setquota-label-Capabilities">Capabilities<span><a href="#method-i-setquota-label-Capabilities">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p>The server’s capabilities must include <code>QUOTA</code> [<a href="https://tools.ietf.org/html/rfc2087">RFC2087</a>].</p>

                              <div class="method-source-code" id="setquota-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1372</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">setquota</span>(<span class="ruby-identifier">mailbox</span>, <span class="ruby-identifier">quota</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">quota</span>.<span class="ruby-identifier">nil?</span>
    <span class="ruby-identifier">data</span> = <span class="ruby-string">&#39;()&#39;</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">data</span> = <span class="ruby-string">&#39;(STORAGE &#39;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">quota</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-string">&#39;)&#39;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;SETQUOTA&quot;</span>, <span class="ruby-identifier">mailbox</span>, <span class="ruby-constant">RawData</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">data</span>))
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-sort" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">sort</span><span
                                class="method-args">(sort_keys, search_keys, charset)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc5256#section-3">SORT command [RFC5256 §3]</a> to search a mailbox for messages that match <code>search_keys</code> and return an array of message sequence numbers, sorted by <code>sort_keys</code>.  <code>search_keys</code> are interpreted the same as for <a href="IMAP.html#method-i-search"><code>search</code></a>.</p>

<p>Related: <a href="IMAP.html#method-i-uid_sort"><code>uid_sort</code></a>, <a href="IMAP.html#method-i-search"><code>search</code></a>, <a href="IMAP.html#method-i-uid_search"><code>uid_search</code></a>, <a href="IMAP.html#method-i-thread"><code>thread</code></a>, <a href="IMAP.html#method-i-uid_thread"><code>uid_thread</code></a></p>

<h5 id="method-i-sort-label-For+example-3A">For example:<span><a href="#method-i-sort-label-For+example-3A">&para;</a> <a href="#top">&uarr;</a></span></h5>

<pre class="ruby"><span class="ruby-identifier">p</span> <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">sort</span>([<span class="ruby-string">&quot;FROM&quot;</span>], [<span class="ruby-string">&quot;ALL&quot;</span>], <span class="ruby-string">&quot;US-ASCII&quot;</span>)
<span class="ruby-comment">#=&gt; [1, 2, 3, 5, 6, 7, 8, 4, 9]</span>
<span class="ruby-identifier">p</span> <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">sort</span>([<span class="ruby-string">&quot;DATE&quot;</span>], [<span class="ruby-string">&quot;SUBJECT&quot;</span>, <span class="ruby-string">&quot;hello&quot;</span>], <span class="ruby-string">&quot;US-ASCII&quot;</span>)
<span class="ruby-comment">#=&gt; [6, 7, 8, 1]</span>
</pre>

<h5 id="method-i-sort-label-Capabilities">Capabilities<span><a href="#method-i-sort-label-Capabilities">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p>The server’s capabilities must include <code>SORT</code> [<a href="https://tools.ietf.org/html/rfc5256">RFC5256</a>].</p>

                              <div class="method-source-code" id="sort-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1829</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">sort</span>(<span class="ruby-identifier">sort_keys</span>, <span class="ruby-identifier">search_keys</span>, <span class="ruby-identifier">charset</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">sort_internal</span>(<span class="ruby-string">&quot;SORT&quot;</span>, <span class="ruby-identifier">sort_keys</span>, <span class="ruby-identifier">search_keys</span>, <span class="ruby-identifier">charset</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-starttls" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">starttls</span><span
                                class="method-args">(options = {}, verify = true)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.2.1">STARTTLS command [IMAP4rev1 §6.2.1]</a> to start a TLS session.</p>

<p>Any <code>options</code> are forwarded to OpenSSL::SSL::SSLContext#set_params.</p>

<p>This method returns after TLS negotiation and hostname verification are both successful.  Any error indicates that the connection has not been secured.</p>

<p><strong>Note:</strong></p>

<blockquote>
<p>Any <a href="IMAP.html#attribute-i-response_handlers"><code>response_handlers</code></a> added before STARTTLS should be aware that the <a href="IMAP/TaggedResponse.html"><code>TaggedResponse</code></a> to STARTTLS is sent clear-text, <em>before</em> TLS negotiation. TLS negotiation starts immediately after that response.</p>
</blockquote>

<p>Related: <a href="IMAP.html#method-c-new"><code>Net::IMAP.new</code></a>, <a href="IMAP.html#method-i-login"><code>login</code></a>, <a href="IMAP.html#method-i-authenticate"><code>authenticate</code></a></p>

<h5 id="method-i-starttls-label-Capability">Capability<span><a href="#method-i-starttls-label-Capability">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p>The server’s capabilities must include <code>STARTTLS</code>.</p>

<p>Server capabilities may change after <a href="IMAP.html#method-i-starttls"><code>starttls</code></a>, <a href="IMAP.html#method-i-login"><code>login</code></a>, and <a href="IMAP.html#method-i-authenticate"><code>authenticate</code></a>. Cached capabilities <em>must</em> be invalidated after this method completes.</p>

<p>The <a href="IMAP/TaggedResponse.html"><code>TaggedResponse</code></a> to <a href="IMAP.html#method-i-starttls"><code>starttls</code></a> is sent clear-text, so the server <em>must <strong>not</em></strong> send capabilities in the <a href="IMAP.html#method-i-starttls"><code>starttls</code></a> response and clients <em>must not</em> use them if they are sent.  Servers will generally send an unsolicited untagged response immeditely <em>after</em> <a href="IMAP.html#method-i-starttls"><code>starttls</code></a> completes.</p>

                              <div class="method-source-code" id="starttls-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 940</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">starttls</span>(<span class="ruby-identifier">options</span> = {}, <span class="ruby-identifier">verify</span> = <span class="ruby-keyword">true</span>)
  <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;STARTTLS&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">resp</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">TaggedResponse</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-string">&quot;OK&quot;</span>
      <span class="ruby-keyword">begin</span>
        <span class="ruby-comment"># for backward compatibility</span>
        <span class="ruby-identifier">certs</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">to_str</span>
        <span class="ruby-identifier">options</span> = <span class="ruby-identifier">create_ssl_params</span>(<span class="ruby-identifier">certs</span>, <span class="ruby-identifier">verify</span>)
      <span class="ruby-keyword">rescue</span> <span class="ruby-constant">NoMethodError</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">start_tls_session</span>(<span class="ruby-identifier">options</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-status" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">status</span><span
                                class="method-args">(mailbox, attr)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.3.10">STATUS commands [IMAP4rev1 §6.3.10]</a> and returns the status of the indicated <code>mailbox</code>. <code>attr</code> is a list of one or more attributes whose statuses are to be requested.  Supported attributes include:</p>

<pre>MESSAGES:: the number of messages in the mailbox.
RECENT:: the number of recent messages in the mailbox.
UNSEEN:: the number of unseen messages in the mailbox.</pre>

<p>The return value is a hash of attributes. For example:</p>

<pre class="ruby"><span class="ruby-identifier">p</span> <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">status</span>(<span class="ruby-string">&quot;inbox&quot;</span>, [<span class="ruby-string">&quot;MESSAGES&quot;</span>, <span class="ruby-string">&quot;RECENT&quot;</span>])
<span class="ruby-comment">#=&gt; {&quot;RECENT&quot;=&gt;0, &quot;MESSAGES&quot;=&gt;44}</span>
</pre>

<p>A <a href="IMAP/NoResponseError.html"><code>Net::IMAP::NoResponseError</code></a> is raised if status values for <code>mailbox</code> cannot be returned; for instance, because it does not exist.</p>

                              <div class="method-source-code" id="status-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1449</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">status</span>(<span class="ruby-identifier">mailbox</span>, <span class="ruby-identifier">attr</span>)
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;STATUS&quot;</span>, <span class="ruby-identifier">mailbox</span>, <span class="ruby-identifier">attr</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-ivar">@responses</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&quot;STATUS&quot;</span>)[<span class="ruby-value">-1</span>].<span class="ruby-identifier">attr</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-store" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">store</span><span
                                class="method-args">(set, attr, flags)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.4.6">STORE command [IMAP4rev1 §6.4.6]</a> to alter data associated with messages in the mailbox, in particular their flags. The <code>set</code> parameter is a number, an array of numbers, or a Range object. Each number is a message sequence number.  <code>attr</code> is the name of a data item to store: ‘FLAGS’ will replace the message’s flag list with the provided one, ‘+FLAGS’ will add the provided flags, and ‘-FLAGS’ will remove them.  <code>flags</code> is a list of flags.</p>

<p>The return value is an array of <a href="IMAP/FetchData.html"><code>FetchData</code></a></p>

<p>Related: <a href="IMAP.html#method-i-uid_store"><code>uid_store</code></a></p>

<h5 id="method-i-store-label-For+example-3A">For example:<span><a href="#method-i-store-label-For+example-3A">&para;</a> <a href="#top">&uarr;</a></span></h5>

<pre class="ruby"><span class="ruby-identifier">p</span> <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">store</span>(<span class="ruby-value">6</span><span class="ruby-operator">..</span><span class="ruby-value">8</span>, <span class="ruby-string">&quot;+FLAGS&quot;</span>, [<span class="ruby-value">:Deleted</span>])
<span class="ruby-comment">#=&gt; [#&lt;Net::IMAP::FetchData seqno=6, attr={&quot;FLAGS&quot;=&gt;[:Seen, :Deleted]}&gt;, \\</span>
     <span class="ruby-comment">#&lt;Net::IMAP::FetchData seqno=7, attr={&quot;FLAGS&quot;=&gt;[:Seen, :Deleted]}&gt;, \\</span>
     <span class="ruby-comment">#&lt;Net::IMAP::FetchData seqno=8, attr={&quot;FLAGS&quot;=&gt;[:Seen, :Deleted]}&gt;]</span>
</pre>

                              <div class="method-source-code" id="store-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1719</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">store</span>(<span class="ruby-identifier">set</span>, <span class="ruby-identifier">attr</span>, <span class="ruby-identifier">flags</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">store_internal</span>(<span class="ruby-string">&quot;STORE&quot;</span>, <span class="ruby-identifier">set</span>, <span class="ruby-identifier">attr</span>, <span class="ruby-identifier">flags</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-subscribe" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">subscribe</span><span
                                class="method-args">(mailbox)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.3.6">SUBSCRIBE command [IMAP4rev1 §6.3.6]</a> to add the specified <code>mailbox</code> name to the server’s set of “active” or “subscribed” mailboxes as returned by <a href="IMAP.html#method-i-lsub"><code>lsub</code></a>.</p>

<p>A <a href="IMAP/NoResponseError.html"><code>Net::IMAP::NoResponseError</code></a> is raised if <code>mailbox</code> cannot be subscribed to; for instance, because it does not exist.</p>

<p>Related: <a href="IMAP.html#method-i-unsubscribe"><code>unsubscribe</code></a>, <a href="IMAP.html#method-i-lsub"><code>lsub</code></a>, <a href="IMAP.html#method-i-list"><code>list</code></a></p>

                              <div class="method-source-code" id="subscribe-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1166</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">subscribe</span>(<span class="ruby-identifier">mailbox</span>)
  <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;SUBSCRIBE&quot;</span>, <span class="ruby-identifier">mailbox</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-thread" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">thread</span><span
                                class="method-args">(algorithm, search_keys, charset)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc5256#section-3">THREAD command [RFC5256 §3]</a> to search a mailbox and return message sequence numbers in threaded format, as a <a href="IMAP/ThreadMember.html"><code>ThreadMember</code></a> tree.  <code>search_keys</code> are interpreted the same as for <a href="IMAP.html#method-i-search"><code>search</code></a>.</p>

<p>The supported algorithms are:</p>
<dl class="rdoc-list note-list"><dt>ORDEREDSUBJECT
<dd>
<p>split into single-level threads according to subject, ordered by date.</p>
</dd><dt>REFERENCES
<dd>
<p>split into threads by parent/child relationships determined by which message is a reply to which.</p>
</dd></dl>

<p>Unlike <a href="IMAP.html#method-i-search"><code>search</code></a>, <code>charset</code> is a required argument.  US-ASCII and UTF-8 are sample values.</p>

<p>Related: <a href="IMAP.html#method-i-uid_thread"><code>uid_thread</code></a>, <a href="IMAP.html#method-i-search"><code>search</code></a>, <a href="IMAP.html#method-i-uid_search"><code>uid_search</code></a>, <a href="IMAP.html#method-i-sort"><code>sort</code></a>, <a href="IMAP.html#method-i-uid_sort"><code>uid_sort</code></a></p>

<h5 id="method-i-thread-label-Capabilities">Capabilities<span><a href="#method-i-thread-label-Capabilities">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p>The server’s capabilities must include <code>THREAD</code> [<a href="https://tools.ietf.org/html/rfc5256">RFC5256</a>].</p>

                              <div class="method-source-code" id="thread-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1869</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">thread</span>(<span class="ruby-identifier">algorithm</span>, <span class="ruby-identifier">search_keys</span>, <span class="ruby-identifier">charset</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">thread_internal</span>(<span class="ruby-string">&quot;THREAD&quot;</span>, <span class="ruby-identifier">algorithm</span>, <span class="ruby-identifier">search_keys</span>, <span class="ruby-identifier">charset</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-uid_copy" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">uid_copy</span><span
                                class="method-args">(set, mailbox)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.4.8">UID COPY command [IMAP4rev1 §6.4.8]</a> to copy the specified message(s) to the end of the specified destination <code>mailbox</code>.</p>

<p>Similar to <a href="IMAP.html#method-i-copy"><code>copy</code></a>, but <code>set</code> contains unique identifiers.</p>

<h5 id="method-i-uid_copy-label-Capabilities">Capabilities<span><a href="#method-i-uid_copy-label-Capabilities">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p><code>UIDPLUS</code> affects <a href="IMAP.html#method-i-uid_copy"><code>uid_copy</code></a> the same way it affects <a href="IMAP.html#method-i-copy"><code>copy</code></a>.</p>

                              <div class="method-source-code" id="uid_copy-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1762</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">uid_copy</span>(<span class="ruby-identifier">set</span>, <span class="ruby-identifier">mailbox</span>)
  <span class="ruby-identifier">copy_internal</span>(<span class="ruby-string">&quot;UID COPY&quot;</span>, <span class="ruby-identifier">set</span>, <span class="ruby-identifier">mailbox</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-uid_expunge" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">uid_expunge</span><span
                                class="method-args">(uid_set)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc4315#section-2.1">UID EXPUNGE command [RFC4315 §2.1]</a> <a href="https://www.rfc-editor.org/rfc/rfc9051#section-6.4.9">[IMAP4rev2 §6.4.9]</a> to permanently remove all messages that have both the <code>\Deleted</code> flag set and a UID that is included in <code>uid_set</code>.</p>

<p>By using <a href="IMAP.html#method-i-uid_expunge"><code>uid_expunge</code></a> instead of <a href="IMAP.html#method-i-expunge"><code>expunge</code></a> when resynchronizing with the server, the client can ensure that it does not inadvertantly remove any messages that have been marked as <code>\Deleted</code> by other clients between the time that the client was last connected and the time the client resynchronizes.</p>

<p><strong>Note:</strong></p>

<blockquote>
<p>Although the command takes a set of UIDs for its argument, the server still returns regular EXPUNGE responses, which contain a <em>sequence number</em>. These will be deleted from <a href="IMAP.html#attribute-i-responses"><code>responses</code></a> and this method returns them as an array of <em>sequence number</em> integers.</p>
</blockquote>

<p>Related: <a href="IMAP.html#method-i-expunge"><code>expunge</code></a></p>

<h5 id="method-i-uid_expunge-label-Capabilities">Capabilities<span><a href="#method-i-uid_expunge-label-Capabilities">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p>The server’s capabilities must include <code>UIDPLUS</code> [<a href="https://www.rfc-editor.org/rfc/rfc4315.html">RFC4315</a>].</p>

                              <div class="method-source-code" id="uid_expunge-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1570</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">uid_expunge</span>(<span class="ruby-identifier">uid_set</span>)
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;UID EXPUNGE&quot;</span>, <span class="ruby-constant">MessageSet</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">uid_set</span>))
    <span class="ruby-keyword">return</span> <span class="ruby-ivar">@responses</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&quot;EXPUNGE&quot;</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-uid_fetch" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">uid_fetch</span><span
                                class="method-args">(set, attr, mod = nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.4.8">UID FETCH command [IMAP4rev1 §6.4.8]</a> to retrieve data associated with a message in the mailbox.</p>

<p>Similar to <a href="IMAP.html#method-i-fetch"><code>fetch</code></a>, but the <code>set</code> parameter contains unique identifiers instead of message sequence numbers.</p>

<blockquote>
<p><strong>Note:</strong> Servers <em>MUST</em> implicitly include the <code>UID</code> message data item as part of any <code>FETCH</code> response caused by a <code>UID</code> command, regardless of whether a <code>UID</code> was specified as a message data item to the <code>FETCH</code>.</p>
</blockquote>

<p>Related: <a href="IMAP.html#method-i-fetch"><code>fetch</code></a>, <a href="IMAP/FetchData.html"><code>FetchData</code></a></p>

                              <div class="method-source-code" id="uid_fetch-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1697</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">uid_fetch</span>(<span class="ruby-identifier">set</span>, <span class="ruby-identifier">attr</span>, <span class="ruby-identifier">mod</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">fetch_internal</span>(<span class="ruby-string">&quot;UID FETCH&quot;</span>, <span class="ruby-identifier">set</span>, <span class="ruby-identifier">attr</span>, <span class="ruby-identifier">mod</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-uid_move" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">uid_move</span><span
                                class="method-args">(set, mailbox)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc6851#section-3.2">UID MOVE command [RFC6851 §3.2]</a> <a href="https://www.rfc-editor.org/rfc/rfc9051#section-6.4.9">[IMAP4rev2 §6.4.9]</a> to move the specified message(s) to the end of the specified destination <code>mailbox</code>.</p>

<p>Similar to <a href="IMAP.html#method-i-move"><code>move</code></a>, but <code>set</code> contains unique identifiers.</p>

<p>Related: <a href="IMAP.html#method-i-move"><code>move</code></a></p>

<h5 id="method-i-uid_move-label-Capabilities">Capabilities<span><a href="#method-i-uid_move-label-Capabilities">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p>Same as <a href="IMAP.html#method-i-move"><code>move</code></a>: The server’s capabilities must include <code>MOVE</code> [<a href="https://tools.ietf.org/html/rfc6851">RFC6851</a>].  <code>UIDPLUS</code> also affects <a href="IMAP.html#method-i-uid_move"><code>uid_move</code></a> the same way it affects <a href="IMAP.html#method-i-move"><code>move</code></a>.</p>

                              <div class="method-source-code" id="uid_move-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1803</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">uid_move</span>(<span class="ruby-identifier">set</span>, <span class="ruby-identifier">mailbox</span>)
  <span class="ruby-identifier">copy_internal</span>(<span class="ruby-string">&quot;UID MOVE&quot;</span>, <span class="ruby-identifier">set</span>, <span class="ruby-identifier">mailbox</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-uid_search" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">uid_search</span><span
                                class="method-args">(keys, charset = nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.4.8">UID SEARCH command [IMAP4rev1 §6.4.8]</a> to search the mailbox for messages that match the given searching criteria, and returns unique identifiers (<code>UID</code>s).</p>

<p>See <a href="IMAP.html#method-i-search"><code>search</code></a> for documentation of search criteria.</p>

                              <div class="method-source-code" id="uid_search-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1640</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">uid_search</span>(<span class="ruby-identifier">keys</span>, <span class="ruby-identifier">charset</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">search_internal</span>(<span class="ruby-string">&quot;UID SEARCH&quot;</span>, <span class="ruby-identifier">keys</span>, <span class="ruby-identifier">charset</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-uid_sort" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">uid_sort</span><span
                                class="method-args">(sort_keys, search_keys, charset)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc5256#section-3">UID SORT command [RFC5256 §3]</a> to search a mailbox for messages that match <code>search_keys</code> and return an array of unique identifiers, sorted by <code>sort_keys</code>.  <code>search_keys</code> are interpreted the same as for <a href="IMAP.html#method-i-search"><code>search</code></a>.</p>

<p>Related: <a href="IMAP.html#method-i-sort"><code>sort</code></a>, <a href="IMAP.html#method-i-search"><code>search</code></a>, <a href="IMAP.html#method-i-uid_search"><code>uid_search</code></a>, <a href="IMAP.html#method-i-thread"><code>thread</code></a>, <a href="IMAP.html#method-i-uid_thread"><code>uid_thread</code></a></p>

<h5 id="method-i-uid_sort-label-Capabilities">Capabilities<span><a href="#method-i-uid_sort-label-Capabilities">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p>The server’s capabilities must include <code>SORT</code> [<a href="https://tools.ietf.org/html/rfc5256">RFC5256</a>].</p>

                              <div class="method-source-code" id="uid_sort-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1844</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">uid_sort</span>(<span class="ruby-identifier">sort_keys</span>, <span class="ruby-identifier">search_keys</span>, <span class="ruby-identifier">charset</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">sort_internal</span>(<span class="ruby-string">&quot;UID SORT&quot;</span>, <span class="ruby-identifier">sort_keys</span>, <span class="ruby-identifier">search_keys</span>, <span class="ruby-identifier">charset</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-uid_store" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">uid_store</span><span
                                class="method-args">(set, attr, flags)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.4.8">UID STORE command [IMAP4rev1 §6.4.8]</a> to alter data associated with messages in the mailbox, in particular their flags.</p>

<p>Similar to <a href="IMAP.html#method-i-store"><code>store</code></a>, but <code>set</code> contains unique identifiers instead of message sequence numbers.</p>

<p>Related: <a href="IMAP.html#method-i-store"><code>store</code></a></p>

                              <div class="method-source-code" id="uid_store-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1731</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">uid_store</span>(<span class="ruby-identifier">set</span>, <span class="ruby-identifier">attr</span>, <span class="ruby-identifier">flags</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">store_internal</span>(<span class="ruby-string">&quot;UID STORE&quot;</span>, <span class="ruby-identifier">set</span>, <span class="ruby-identifier">attr</span>, <span class="ruby-identifier">flags</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-uid_thread" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">uid_thread</span><span
                                class="method-args">(algorithm, search_keys, charset)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a <a href="https://www.rfc-editor.org/rfc/rfc5256#section-3">UID THREAD command [RFC5256 §3]</a> Similar to <a href="IMAP.html#method-i-thread"><code>thread</code></a>, but returns unique identifiers instead of message sequence numbers.</p>

<p>Related: <a href="IMAP.html#method-i-thread"><code>thread</code></a>, <a href="IMAP.html#method-i-search"><code>search</code></a>, <a href="IMAP.html#method-i-uid_search"><code>uid_search</code></a>, <a href="IMAP.html#method-i-sort"><code>sort</code></a>, <a href="IMAP.html#method-i-uid_sort"><code>uid_sort</code></a></p>

<h5 id="method-i-uid_thread-label-Capabilities">Capabilities<span><a href="#method-i-uid_thread-label-Capabilities">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p>The server’s capabilities must include <code>THREAD</code> [<a href="https://tools.ietf.org/html/rfc5256">RFC5256</a>].</p>

                              <div class="method-source-code" id="uid_thread-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1883</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">uid_thread</span>(<span class="ruby-identifier">algorithm</span>, <span class="ruby-identifier">search_keys</span>, <span class="ruby-identifier">charset</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">thread_internal</span>(<span class="ruby-string">&quot;UID THREAD&quot;</span>, <span class="ruby-identifier">algorithm</span>, <span class="ruby-identifier">search_keys</span>, <span class="ruby-identifier">charset</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-unselect" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">unselect</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends an <a href="https://www.rfc-editor.org/rfc/rfc3691#section-3">UNSELECT command [RFC3691 §2]</a> <a href="https://www.rfc-editor.org/rfc/rfc9051#section-6.4.2">[IMAP4rev2 §6.4.2]</a> to free the session resources for a mailbox and return to the “<em>authenticated</em>” state.  This is the same as <a href="IMAP.html#method-i-close"><code>close</code></a>, except that <code>\Deleted</code> messages are not removed from the mailbox.</p>

<p>Related: <a href="IMAP.html#method-i-close"><code>close</code></a></p>

<h5 id="method-i-unselect-label-Capabilities">Capabilities<span><a href="#method-i-unselect-label-Capabilities">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p>The server’s capabilities must include <code>UNSELECT</code> [<a href="https://tools.ietf.org/html/rfc3691">RFC3691</a>].</p>

                              <div class="method-source-code" id="unselect-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1529</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">unselect</span>
  <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;UNSELECT&quot;</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-unsubscribe" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">unsubscribe</span><span
                                class="method-args">(mailbox)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends an <a href="https://www.rfc-editor.org/rfc/rfc3501#section-6.3.7">UNSUBSCRIBE command [IMAP4rev1 §6.3.7]</a> to remove the specified <code>mailbox</code> name from the server’s set of “active” or “subscribed” mailboxes.</p>

<p>A <a href="IMAP/NoResponseError.html"><code>Net::IMAP::NoResponseError</code></a> is raised if <code>mailbox</code> cannot be unsubscribed from; for instance, because the client is not currently subscribed to it.</p>

<p>Related: <a href="IMAP.html#method-i-subscribe"><code>subscribe</code></a>, <a href="IMAP.html#method-i-lsub"><code>lsub</code></a>, <a href="IMAP.html#method-i-list"><code>list</code></a></p>

                              <div class="method-source-code" id="unsubscribe-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1179</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">unsubscribe</span>(<span class="ruby-identifier">mailbox</span>)
  <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;UNSUBSCRIBE&quot;</span>, <span class="ruby-identifier">mailbox</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-xlist" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">xlist</span><span
                                class="method-args">(refname, mailbox)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends a XLIST command, and returns a subset of names from the complete set of all names available to the client. <code>refname</code> provides a context (for instance, a base directory in a directory-based mailbox hierarchy).  <code>mailbox</code> specifies a mailbox or (via wildcards) mailboxes under that context. Two wildcards may be used in <code>mailbox</code>: ‘*’, which matches all characters <strong>including</strong> the hierarchy delimiter (for instance, ‘/’ on a UNIX-hosted directory-based mailbox hierarchy); and ‘%’, which matches all characters <strong>except</strong> the hierarchy delimiter.</p>

<p>If <code>refname</code> is empty, <code>mailbox</code> is used directly to determine which mailboxes to match.  If <code>mailbox</code> is empty, the root name of <code>refname</code> and the hierarchy delimiter are returned.</p>

<p>The XLIST command is like the LIST command except that the flags returned refer to the function of the folder/mailbox, e.g. :Sent</p>

<p>The return value is an array of <a href="IMAP/MailboxList.html"><code>MailboxList</code></a> objects. For example:</p>

<pre class="ruby"><span class="ruby-identifier">imap</span>.<span class="ruby-identifier">create</span>(<span class="ruby-string">&quot;foo/bar&quot;</span>)
<span class="ruby-identifier">imap</span>.<span class="ruby-identifier">create</span>(<span class="ruby-string">&quot;foo/baz&quot;</span>)
<span class="ruby-identifier">p</span> <span class="ruby-identifier">imap</span>.<span class="ruby-identifier">xlist</span>(<span class="ruby-string">&quot;&quot;</span>, <span class="ruby-string">&quot;foo/%&quot;</span>)
<span class="ruby-comment">#=&gt; [#&lt;Net::IMAP::MailboxList attr=[:Noselect], delim=&quot;/&quot;, name=&quot;foo/&quot;&gt;, \\</span>
     <span class="ruby-comment">#&lt;Net::IMAP::MailboxList attr=[:Noinferiors, :Marked], delim=&quot;/&quot;, name=&quot;foo/bar&quot;&gt;, \\</span>
     <span class="ruby-comment">#&lt;Net::IMAP::MailboxList attr=[:Noinferiors], delim=&quot;/&quot;, name=&quot;foo/baz&quot;&gt;]</span>
</pre>

<p>Related: <a href="IMAP.html#method-i-list"><code>list</code></a>, <a href="IMAP/MailboxList.html"><code>MailboxList</code></a></p>

<h5 id="method-i-xlist-label-Capabilities">Capabilities<span><a href="#method-i-xlist-label-Capabilities">&para;</a> <a href="#top">&uarr;</a></span></h5>

<p>The server’s capabilities must include <code>XLIST</code>, a deprecated Gmail extension (replaced by <code>SPECIAL-USE</code>).</p>

                              <div class="method-source-code" id="xlist-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 1315</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">xlist</span>(<span class="ruby-identifier">refname</span>, <span class="ruby-identifier">mailbox</span>)
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">send_command</span>(<span class="ruby-string">&quot;XLIST&quot;</span>, <span class="ruby-identifier">refname</span>, <span class="ruby-identifier">mailbox</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-ivar">@responses</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&quot;XLIST&quot;</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="private-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Instance Methods</h3>
                </header>

                  <div id="method-i-copy_internal" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">copy_internal</span><span
                                class="method-args">(cmd, set, mailbox)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="copy_internal-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 2301</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">copy_internal</span>(<span class="ruby-identifier">cmd</span>, <span class="ruby-identifier">set</span>, <span class="ruby-identifier">mailbox</span>)
  <span class="ruby-identifier">send_command</span>(<span class="ruby-identifier">cmd</span>, <span class="ruby-constant">MessageSet</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">set</span>), <span class="ruby-identifier">mailbox</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-create_ssl_params" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">create_ssl_params</span><span
                                class="method-args">(certs = nil, verify = true)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="create_ssl_params-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 2340</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">create_ssl_params</span>(<span class="ruby-identifier">certs</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">verify</span> = <span class="ruby-keyword">true</span>)
  <span class="ruby-identifier">params</span> = {}
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">certs</span>
    <span class="ruby-keyword">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-identifier">certs</span>)
      <span class="ruby-identifier">params</span>[<span class="ruby-value">:ca_file</span>] = <span class="ruby-identifier">certs</span>
    <span class="ruby-keyword">elsif</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">certs</span>)
      <span class="ruby-identifier">params</span>[<span class="ruby-value">:ca_path</span>] = <span class="ruby-identifier">certs</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">verify</span>
    <span class="ruby-identifier">params</span>[<span class="ruby-value">:verify_mode</span>] = <span class="ruby-constant">VERIFY_PEER</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">params</span>[<span class="ruby-value">:verify_mode</span>] = <span class="ruby-constant">VERIFY_NONE</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">params</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-fetch_internal" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">fetch_internal</span><span
                                class="method-args">(cmd, set, attr, mod = nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="fetch_internal-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 2269</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">fetch_internal</span>(<span class="ruby-identifier">cmd</span>, <span class="ruby-identifier">set</span>, <span class="ruby-identifier">attr</span>, <span class="ruby-identifier">mod</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">attr</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">String</span> <span class="ruby-keyword">then</span>
    <span class="ruby-identifier">attr</span> = <span class="ruby-constant">RawData</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">attr</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Array</span> <span class="ruby-keyword">then</span>
    <span class="ruby-identifier">attr</span> = <span class="ruby-identifier">attr</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">arg</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>) <span class="ruby-operator">?</span> <span class="ruby-constant">RawData</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">arg</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">arg</span>
    }
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-ivar">@responses</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&quot;FETCH&quot;</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">mod</span>
      <span class="ruby-identifier">send_command</span>(<span class="ruby-identifier">cmd</span>, <span class="ruby-constant">MessageSet</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">set</span>), <span class="ruby-identifier">attr</span>, <span class="ruby-identifier">mod</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">send_command</span>(<span class="ruby-identifier">cmd</span>, <span class="ruby-constant">MessageSet</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">set</span>), <span class="ruby-identifier">attr</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">return</span> <span class="ruby-ivar">@responses</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&quot;FETCH&quot;</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-generate_tag" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">generate_tag</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="generate_tag-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 2233</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">generate_tag</span>
  <span class="ruby-ivar">@tagno</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">format</span>(<span class="ruby-string">&quot;%s%04d&quot;</span>, <span class="ruby-ivar">@tag_prefix</span>, <span class="ruby-ivar">@tagno</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-get_response" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">get_response</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="get_response-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 2178</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">get_response</span>
  <span class="ruby-identifier">buff</span> = <span class="ruby-constant">String</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-keyword">while</span> <span class="ruby-keyword">true</span>
    <span class="ruby-identifier">s</span> = <span class="ruby-ivar">@sock</span>.<span class="ruby-identifier">gets</span>(<span class="ruby-constant">CRLF</span>)
    <span class="ruby-keyword">break</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">s</span>
    <span class="ruby-identifier">buff</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">s</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-regexp">/\{(\d+)\}\r\n/n</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">s</span>
      <span class="ruby-identifier">s</span> = <span class="ruby-ivar">@sock</span>.<span class="ruby-identifier">read</span>(<span class="ruby-node">$1</span>.<span class="ruby-identifier">to_i</span>)
      <span class="ruby-identifier">buff</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">s</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-keyword">break</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">buff</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">@@debug</span>
    <span class="ruby-identifier">$stderr</span>.<span class="ruby-identifier">print</span>(<span class="ruby-identifier">buff</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/^/n</span>, <span class="ruby-string">&quot;S: &quot;</span>))
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">return</span> <span class="ruby-ivar">@parser</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">buff</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-get_tagged_response" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">get_tagged_response</span><span
                                class="method-args">(tag, cmd, timeout = nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="get_tagged_response-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 2151</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">get_tagged_response</span>(<span class="ruby-identifier">tag</span>, <span class="ruby-identifier">cmd</span>, <span class="ruby-identifier">timeout</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">timeout</span>
    <span class="ruby-identifier">deadline</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">timeout</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">until</span> <span class="ruby-ivar">@tagged_responses</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">tag</span>)
    <span class="ruby-identifier">raise</span> <span class="ruby-ivar">@exception</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@exception</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">timeout</span>
      <span class="ruby-identifier">timeout</span> = <span class="ruby-identifier">deadline</span> <span class="ruby-operator">-</span> <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">timeout</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-value">0</span>
        <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-ivar">@tagged_response_arrival</span>.<span class="ruby-identifier">wait</span>(<span class="ruby-identifier">timeout</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">resp</span> = <span class="ruby-ivar">@tagged_responses</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">tag</span>)
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">name</span>
  <span class="ruby-keyword">when</span> <span class="ruby-regexp">/\A(?:OK)\z/ni</span>
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">resp</span>
  <span class="ruby-keyword">when</span> <span class="ruby-regexp">/\A(?:NO)\z/ni</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">NoResponseError</span>, <span class="ruby-identifier">resp</span>
  <span class="ruby-keyword">when</span> <span class="ruby-regexp">/\A(?:BAD)\z/ni</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">BadResponseError</span>, <span class="ruby-identifier">resp</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">UnknownResponseError</span>, <span class="ruby-identifier">resp</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-normalize_searching_criteria" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">normalize_searching_criteria</span><span
                                class="method-args">(keys)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="normalize_searching_criteria-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 2329</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">normalize_searching_criteria</span>(<span class="ruby-identifier">keys</span>)
  <span class="ruby-identifier">keys</span>.<span class="ruby-identifier">collect!</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">case</span> <span class="ruby-identifier">i</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">-1</span>, <span class="ruby-constant">Range</span>, <span class="ruby-constant">Array</span>
      <span class="ruby-constant">MessageSet</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">i</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">i</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-put_string" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">put_string</span><span
                                class="method-args">(str)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="put_string-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 2238</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">put_string</span>(<span class="ruby-identifier">str</span>)
  <span class="ruby-ivar">@sock</span>.<span class="ruby-identifier">print</span>(<span class="ruby-identifier">str</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">@@debug</span>
    <span class="ruby-keyword">if</span> <span class="ruby-ivar">@debug_output_bol</span>
      <span class="ruby-identifier">$stderr</span>.<span class="ruby-identifier">print</span>(<span class="ruby-string">&quot;C: &quot;</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">$stderr</span>.<span class="ruby-identifier">print</span>(<span class="ruby-identifier">str</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/\n(?!\z)/n</span>, <span class="ruby-string">&quot;\nC: &quot;</span>))
    <span class="ruby-keyword">if</span> <span class="ruby-regexp">/\r\n\z/n</span>.<span class="ruby-identifier">match</span>(<span class="ruby-identifier">str</span>)
      <span class="ruby-ivar">@debug_output_bol</span> = <span class="ruby-keyword">true</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-ivar">@debug_output_bol</span> = <span class="ruby-keyword">false</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-receive_responses" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">receive_responses</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="receive_responses-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 2080</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">receive_responses</span>
  <span class="ruby-identifier">connection_closed</span> = <span class="ruby-keyword">false</span>
  <span class="ruby-keyword">until</span> <span class="ruby-identifier">connection_closed</span>
    <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
      <span class="ruby-ivar">@exception</span> = <span class="ruby-keyword">nil</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">begin</span>
      <span class="ruby-identifier">resp</span> = <span class="ruby-identifier">get_response</span>
    <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Exception</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">e</span>
      <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
        <span class="ruby-ivar">@sock</span>.<span class="ruby-identifier">close</span>
        <span class="ruby-ivar">@exception</span> = <span class="ruby-identifier">e</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">break</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">unless</span> <span class="ruby-identifier">resp</span>
      <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
        <span class="ruby-ivar">@exception</span> = <span class="ruby-constant">EOFError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;end of file reached&quot;</span>)
      <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">break</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">begin</span>
      <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
        <span class="ruby-keyword">case</span> <span class="ruby-identifier">resp</span>
        <span class="ruby-keyword">when</span> <span class="ruby-constant">TaggedResponse</span>
          <span class="ruby-ivar">@tagged_responses</span>[<span class="ruby-identifier">resp</span>.<span class="ruby-identifier">tag</span>] = <span class="ruby-identifier">resp</span>
          <span class="ruby-ivar">@tagged_response_arrival</span>.<span class="ruby-identifier">broadcast</span>
          <span class="ruby-keyword">case</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">tag</span>
          <span class="ruby-keyword">when</span> <span class="ruby-ivar">@logout_command_tag</span>
            <span class="ruby-keyword">return</span>
          <span class="ruby-keyword">when</span> <span class="ruby-ivar">@continued_command_tag</span>
            <span class="ruby-ivar">@continuation_request_exception</span> =
              <span class="ruby-constant">RESPONSE_ERRORS</span>[<span class="ruby-identifier">resp</span>.<span class="ruby-identifier">name</span>].<span class="ruby-identifier">new</span>(<span class="ruby-identifier">resp</span>)
            <span class="ruby-ivar">@continuation_request_arrival</span>.<span class="ruby-identifier">signal</span>
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">when</span> <span class="ruby-constant">UntaggedResponse</span>
          <span class="ruby-identifier">record_response</span>(<span class="ruby-identifier">resp</span>.<span class="ruby-identifier">name</span>, <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">data</span>)
          <span class="ruby-keyword">if</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">data</span>.<span class="ruby-identifier">instance_of?</span>(<span class="ruby-constant">ResponseText</span>) <span class="ruby-operator">&amp;&amp;</span>
              (<span class="ruby-identifier">code</span> = <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">data</span>.<span class="ruby-identifier">code</span>)
            <span class="ruby-identifier">record_response</span>(<span class="ruby-identifier">code</span>.<span class="ruby-identifier">name</span>, <span class="ruby-identifier">code</span>.<span class="ruby-identifier">data</span>)
          <span class="ruby-keyword">end</span>
          <span class="ruby-keyword">if</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-string">&quot;BYE&quot;</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@logout_command_tag</span>.<span class="ruby-identifier">nil?</span>
            <span class="ruby-ivar">@sock</span>.<span class="ruby-identifier">close</span>
            <span class="ruby-ivar">@exception</span> = <span class="ruby-constant">ByeResponseError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">resp</span>)
            <span class="ruby-identifier">connection_closed</span> = <span class="ruby-keyword">true</span>
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">when</span> <span class="ruby-constant">ContinuationRequest</span>
          <span class="ruby-ivar">@continuation_request_arrival</span>.<span class="ruby-identifier">signal</span>
        <span class="ruby-keyword">end</span>
        <span class="ruby-ivar">@response_handlers</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">handler</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">handler</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">resp</span>)
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Exception</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">e</span>
      <span class="ruby-ivar">@exception</span> = <span class="ruby-identifier">e</span>
      <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
        <span class="ruby-ivar">@tagged_response_arrival</span>.<span class="ruby-identifier">broadcast</span>
        <span class="ruby-ivar">@continuation_request_arrival</span>.<span class="ruby-identifier">broadcast</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-ivar">@receiver_thread_terminating</span> = <span class="ruby-keyword">true</span>
    <span class="ruby-ivar">@tagged_response_arrival</span>.<span class="ruby-identifier">broadcast</span>
    <span class="ruby-ivar">@continuation_request_arrival</span>.<span class="ruby-identifier">broadcast</span>
    <span class="ruby-keyword">if</span> <span class="ruby-ivar">@idle_done_cond</span>
      <span class="ruby-ivar">@idle_done_cond</span>.<span class="ruby-identifier">signal</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-record_response" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">record_response</span><span
                                class="method-args">(name, data)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="record_response-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 2198</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">record_response</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">data</span>)
  <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@responses</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">name</span>)
    <span class="ruby-ivar">@responses</span>[<span class="ruby-identifier">name</span>] = []
  <span class="ruby-keyword">end</span>
  <span class="ruby-ivar">@responses</span>[<span class="ruby-identifier">name</span>].<span class="ruby-identifier">push</span>(<span class="ruby-identifier">data</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-search_internal" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">search_internal</span><span
                                class="method-args">(cmd, keys, charset)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="search_internal-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 2253</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">search_internal</span>(<span class="ruby-identifier">cmd</span>, <span class="ruby-identifier">keys</span>, <span class="ruby-identifier">charset</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">keys</span>.<span class="ruby-identifier">instance_of?</span>(<span class="ruby-constant">String</span>)
    <span class="ruby-identifier">keys</span> = [<span class="ruby-constant">RawData</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">keys</span>)]
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">normalize_searching_criteria</span>(<span class="ruby-identifier">keys</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">charset</span>
      <span class="ruby-identifier">send_command</span>(<span class="ruby-identifier">cmd</span>, <span class="ruby-string">&quot;CHARSET&quot;</span>, <span class="ruby-identifier">charset</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">keys</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">send_command</span>(<span class="ruby-identifier">cmd</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">keys</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">return</span> <span class="ruby-ivar">@responses</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&quot;SEARCH&quot;</span>)[<span class="ruby-value">-1</span>]
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-send_command" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">send_command</span><span
                                class="method-args">(cmd, *args, &amp;block)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="send_command-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 2205</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">send_command</span>(<span class="ruby-identifier">cmd</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">args</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">validate_data</span>(<span class="ruby-identifier">i</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">tag</span> = <span class="ruby-identifier">generate_tag</span>
    <span class="ruby-identifier">put_string</span>(<span class="ruby-identifier">tag</span> <span class="ruby-operator">+</span> <span class="ruby-string">&quot; &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">cmd</span>)
    <span class="ruby-identifier">args</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">put_string</span>(<span class="ruby-string">&quot; &quot;</span>)
      <span class="ruby-identifier">send_data</span>(<span class="ruby-identifier">i</span>, <span class="ruby-identifier">tag</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">put_string</span>(<span class="ruby-constant">CRLF</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">cmd</span> <span class="ruby-operator">==</span> <span class="ruby-string">&quot;LOGOUT&quot;</span>
      <span class="ruby-ivar">@logout_command_tag</span> = <span class="ruby-identifier">tag</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">block</span>
      <span class="ruby-identifier">add_response_handler</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">begin</span>
      <span class="ruby-keyword">return</span> <span class="ruby-identifier">get_tagged_response</span>(<span class="ruby-identifier">tag</span>, <span class="ruby-identifier">cmd</span>)
    <span class="ruby-keyword">ensure</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">block</span>
        <span class="ruby-identifier">remove_response_handler</span>(<span class="ruby-identifier">block</span>)
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-send_data" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">send_data</span><span
                                class="method-args">(data, tag = nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="send_data-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap/command_data.rb, line 33</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">send_data</span>(<span class="ruby-identifier">data</span>, <span class="ruby-identifier">tag</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">data</span>
  <span class="ruby-keyword">when</span> <span class="ruby-keyword">nil</span>
    <span class="ruby-identifier">put_string</span>(<span class="ruby-string">&quot;NIL&quot;</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-constant">String</span>
    <span class="ruby-identifier">send_string_data</span>(<span class="ruby-identifier">data</span>, <span class="ruby-identifier">tag</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Integer</span>
    <span class="ruby-identifier">send_number_data</span>(<span class="ruby-identifier">data</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Array</span>
    <span class="ruby-identifier">send_list_data</span>(<span class="ruby-identifier">data</span>, <span class="ruby-identifier">tag</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Date</span>
    <span class="ruby-identifier">send_date_data</span>(<span class="ruby-identifier">data</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Time</span>, <span class="ruby-constant">DateTime</span>
    <span class="ruby-identifier">send_time_data</span>(<span class="ruby-identifier">data</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Symbol</span>
    <span class="ruby-identifier">send_symbol_data</span>(<span class="ruby-identifier">data</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">data</span>.<span class="ruby-identifier">send_data</span>(<span class="ruby-keyword">self</span>, <span class="ruby-identifier">tag</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-send_date_data" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">send_date_data</span><span
                                class="method-args">(date)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="send_date_data-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap/command_data.rb, line 108</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">send_date_data</span>(<span class="ruby-identifier">date</span>) <span class="ruby-identifier">put_string</span> <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">IMAP</span>.<span class="ruby-identifier">encode_date</span>(<span class="ruby-identifier">date</span>) <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-send_list_data" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">send_list_data</span><span
                                class="method-args">(list, tag = nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="send_list_data-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap/command_data.rb, line 94</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">send_list_data</span>(<span class="ruby-identifier">list</span>, <span class="ruby-identifier">tag</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">put_string</span>(<span class="ruby-string">&quot;(&quot;</span>)
  <span class="ruby-identifier">first</span> = <span class="ruby-keyword">true</span>
  <span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">first</span>
      <span class="ruby-identifier">first</span> = <span class="ruby-keyword">false</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">put_string</span>(<span class="ruby-string">&quot; &quot;</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">send_data</span>(<span class="ruby-identifier">i</span>, <span class="ruby-identifier">tag</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">put_string</span>(<span class="ruby-string">&quot;)&quot;</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-send_literal" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">send_literal</span><span
                                class="method-args">(str, tag = nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="send_literal-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap/command_data.rb, line 73</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">send_literal</span>(<span class="ruby-identifier">str</span>, <span class="ruby-identifier">tag</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">put_string</span>(<span class="ruby-string">&quot;{&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">str</span>.<span class="ruby-identifier">bytesize</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-string">&quot;}&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-constant">CRLF</span>)
    <span class="ruby-ivar">@continued_command_tag</span> = <span class="ruby-identifier">tag</span>
    <span class="ruby-ivar">@continuation_request_exception</span> = <span class="ruby-keyword">nil</span>
    <span class="ruby-keyword">begin</span>
      <span class="ruby-ivar">@continuation_request_arrival</span>.<span class="ruby-identifier">wait</span>
      <span class="ruby-identifier">e</span> = <span class="ruby-ivar">@continuation_request_exception</span> <span class="ruby-operator">||</span> <span class="ruby-ivar">@exception</span>
      <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">e</span>
      <span class="ruby-identifier">put_string</span>(<span class="ruby-identifier">str</span>)
    <span class="ruby-keyword">ensure</span>
      <span class="ruby-ivar">@continued_command_tag</span> = <span class="ruby-keyword">nil</span>
      <span class="ruby-ivar">@continuation_request_exception</span> = <span class="ruby-keyword">nil</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-send_number_data" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">send_number_data</span><span
                                class="method-args">(num)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="send_number_data-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap/command_data.rb, line 90</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">send_number_data</span>(<span class="ruby-identifier">num</span>)
  <span class="ruby-identifier">put_string</span>(<span class="ruby-identifier">num</span>.<span class="ruby-identifier">to_s</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-send_quoted_string" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">send_quoted_string</span><span
                                class="method-args">(str)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="send_quoted_string-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap/command_data.rb, line 69</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">send_quoted_string</span>(<span class="ruby-identifier">str</span>)
  <span class="ruby-identifier">put_string</span>(<span class="ruby-string">&#39;&quot;&#39;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">str</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/[&quot;\\]/n</span>, <span class="ruby-string">&quot;\\\\\\&amp;&quot;</span>) <span class="ruby-operator">+</span> <span class="ruby-string">&#39;&quot;&#39;</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-send_string_data" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">send_string_data</span><span
                                class="method-args">(str, tag = nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="send_string_data-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap/command_data.rb, line 54</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">send_string_data</span>(<span class="ruby-identifier">str</span>, <span class="ruby-identifier">tag</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">str</span>
  <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;&quot;</span>
    <span class="ruby-identifier">put_string</span>(<span class="ruby-string">&#39;&quot;&quot;&#39;</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-regexp">/[\x80-\xff\r\n]/n</span>
    <span class="ruby-comment"># literal</span>
    <span class="ruby-identifier">send_literal</span>(<span class="ruby-identifier">str</span>, <span class="ruby-identifier">tag</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-regexp">/[(){ \x00-\x1f\x7f%*&quot;\\]/n</span>
    <span class="ruby-comment"># quoted string</span>
    <span class="ruby-identifier">send_quoted_string</span>(<span class="ruby-identifier">str</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">put_string</span>(<span class="ruby-identifier">str</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-send_symbol_data" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">send_symbol_data</span><span
                                class="method-args">(symbol)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="send_symbol_data-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap/command_data.rb, line 111</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">send_symbol_data</span>(<span class="ruby-identifier">symbol</span>)
  <span class="ruby-identifier">put_string</span>(<span class="ruby-string">&quot;\\&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">symbol</span>.<span class="ruby-identifier">to_s</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-send_time_data" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">send_time_data</span><span
                                class="method-args">(time)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="send_time_data-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap/command_data.rb, line 109</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">send_time_data</span>(<span class="ruby-identifier">time</span>) <span class="ruby-identifier">put_string</span> <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">IMAP</span>.<span class="ruby-identifier">encode_time</span>(<span class="ruby-identifier">time</span>) <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-sort_internal" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">sort_internal</span><span
                                class="method-args">(cmd, sort_keys, search_keys, charset)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="sort_internal-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 2305</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">sort_internal</span>(<span class="ruby-identifier">cmd</span>, <span class="ruby-identifier">sort_keys</span>, <span class="ruby-identifier">search_keys</span>, <span class="ruby-identifier">charset</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">search_keys</span>.<span class="ruby-identifier">instance_of?</span>(<span class="ruby-constant">String</span>)
    <span class="ruby-identifier">search_keys</span> = [<span class="ruby-constant">RawData</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">search_keys</span>)]
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">normalize_searching_criteria</span>(<span class="ruby-identifier">search_keys</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">normalize_searching_criteria</span>(<span class="ruby-identifier">search_keys</span>)
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">send_command</span>(<span class="ruby-identifier">cmd</span>, <span class="ruby-identifier">sort_keys</span>, <span class="ruby-identifier">charset</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">search_keys</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-ivar">@responses</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&quot;SORT&quot;</span>)[<span class="ruby-value">-1</span>]
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-start_tls_session" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">start_tls_session</span><span
                                class="method-args">(params = {})</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="start_tls_session-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 2357</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">start_tls_session</span>(<span class="ruby-identifier">params</span> = {})
  <span class="ruby-keyword">unless</span> <span class="ruby-keyword">defined?</span>(<span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSL</span>)
    <span class="ruby-identifier">raise</span> <span class="ruby-string">&quot;SSL extension not installed&quot;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@sock</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSLSocket</span>)
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">RuntimeError</span>, <span class="ruby-string">&quot;already using SSL&quot;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">begin</span>
    <span class="ruby-identifier">params</span> = <span class="ruby-identifier">params</span>.<span class="ruby-identifier">to_hash</span>
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">NoMethodError</span>
    <span class="ruby-identifier">params</span> = {}
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">context</span> = <span class="ruby-constant">SSLContext</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-identifier">context</span>.<span class="ruby-identifier">set_params</span>(<span class="ruby-identifier">params</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-keyword">defined?</span>(<span class="ruby-constant">VerifyCallbackProc</span>)
    <span class="ruby-identifier">context</span>.<span class="ruby-identifier">verify_callback</span> = <span class="ruby-constant">VerifyCallbackProc</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-ivar">@sock</span> = <span class="ruby-constant">SSLSocket</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@sock</span>, <span class="ruby-identifier">context</span>)
  <span class="ruby-ivar">@sock</span>.<span class="ruby-identifier">sync_close</span> = <span class="ruby-keyword">true</span>
  <span class="ruby-ivar">@sock</span>.<span class="ruby-identifier">hostname</span> = <span class="ruby-ivar">@host</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@sock</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-value">:hostname=</span>
  <span class="ruby-identifier">ssl_socket_connect</span>(<span class="ruby-ivar">@sock</span>, <span class="ruby-ivar">@open_timeout</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">context</span>.<span class="ruby-identifier">verify_mode</span> <span class="ruby-operator">!=</span> <span class="ruby-constant">VERIFY_NONE</span>
    <span class="ruby-ivar">@sock</span>.<span class="ruby-identifier">post_connection_check</span>(<span class="ruby-ivar">@host</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-store_internal" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">store_internal</span><span
                                class="method-args">(cmd, set, attr, flags)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="store_internal-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 2290</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">store_internal</span>(<span class="ruby-identifier">cmd</span>, <span class="ruby-identifier">set</span>, <span class="ruby-identifier">attr</span>, <span class="ruby-identifier">flags</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">attr</span>.<span class="ruby-identifier">instance_of?</span>(<span class="ruby-constant">String</span>)
    <span class="ruby-identifier">attr</span> = <span class="ruby-constant">RawData</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">attr</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-ivar">@responses</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&quot;FETCH&quot;</span>)
    <span class="ruby-identifier">send_command</span>(<span class="ruby-identifier">cmd</span>, <span class="ruby-constant">MessageSet</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">set</span>), <span class="ruby-identifier">attr</span>, <span class="ruby-identifier">flags</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-ivar">@responses</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&quot;FETCH&quot;</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-tcp_socket" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">tcp_socket</span><span
                                class="method-args">(host, port)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="tcp_socket-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 2071</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">tcp_socket</span>(<span class="ruby-identifier">host</span>, <span class="ruby-identifier">port</span>)
  <span class="ruby-identifier">s</span> = <span class="ruby-constant">Socket</span>.<span class="ruby-identifier">tcp</span>(<span class="ruby-identifier">host</span>, <span class="ruby-identifier">port</span>, <span class="ruby-value">:connect_timeout</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-ivar">@open_timeout</span>)
  <span class="ruby-identifier">s</span>.<span class="ruby-identifier">setsockopt</span>(<span class="ruby-value">:SOL_SOCKET</span>, <span class="ruby-value">:SO_KEEPALIVE</span>, <span class="ruby-keyword">true</span>)
  <span class="ruby-identifier">s</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ETIMEDOUT</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">OpenTimeout</span>, <span class="ruby-string">&quot;Timeout to open TCP connection to &quot;</span> <span class="ruby-operator">+</span>
    <span class="ruby-node">&quot;#{host}:#{port} (exceeds #{@open_timeout} seconds)&quot;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-thread_internal" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">thread_internal</span><span
                                class="method-args">(cmd, algorithm, search_keys, charset)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="thread_internal-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap.rb, line 2318</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">thread_internal</span>(<span class="ruby-identifier">cmd</span>, <span class="ruby-identifier">algorithm</span>, <span class="ruby-identifier">search_keys</span>, <span class="ruby-identifier">charset</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">search_keys</span>.<span class="ruby-identifier">instance_of?</span>(<span class="ruby-constant">String</span>)
    <span class="ruby-identifier">search_keys</span> = [<span class="ruby-constant">RawData</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">search_keys</span>)]
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">normalize_searching_criteria</span>(<span class="ruby-identifier">search_keys</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">normalize_searching_criteria</span>(<span class="ruby-identifier">search_keys</span>)
  <span class="ruby-identifier">send_command</span>(<span class="ruby-identifier">cmd</span>, <span class="ruby-identifier">algorithm</span>, <span class="ruby-identifier">charset</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">search_keys</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-ivar">@responses</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&quot;THREAD&quot;</span>)[<span class="ruby-value">-1</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-validate_data" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">validate_data</span><span
                                class="method-args">(data)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="validate_data-source">
            <pre><span class="ruby-comment"># File net-imap-0.3.7/lib/net/imap/command_data.rb, line 12</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">validate_data</span>(<span class="ruby-identifier">data</span>)
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">data</span>
  <span class="ruby-keyword">when</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">String</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Integer</span>
    <span class="ruby-constant">NumValidator</span>.<span class="ruby-identifier">ensure_number</span>(<span class="ruby-identifier">data</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Array</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">data</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">==</span> <span class="ruby-string">&#39;CHANGEDSINCE&#39;</span>
      <span class="ruby-constant">NumValidator</span>.<span class="ruby-identifier">ensure_mod_sequence_value</span>(<span class="ruby-identifier">data</span>[<span class="ruby-value">1</span>])
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">data</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">validate_data</span>(<span class="ruby-identifier">i</span>)
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Time</span>, <span class="ruby-constant">Date</span>, <span class="ruby-constant">DateTime</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Symbol</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">data</span>.<span class="ruby-identifier">validate</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
      <section id="Basic+Mailbox+Attributes" class="documentation-section">
      <header class="documentation-section-title">
      <h2>
        Basic Mailbox Attributes
      </h2>
      <span class="section-click-top">
        <a href="#top">&uarr; top</a>
      </span>
      </header>


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="HASCHILDREN">HASCHILDREN
          <dd><p>Alias for <a href="IMAP.html#HAS_CHILDREN"><code>HAS_CHILDREN</code></a>, to match the IMAP spelling.</p>
          <dt id="HASNOCHILDREN">HASNOCHILDREN
          <dd><p>Alias for <a href="IMAP.html#HAS_NO_CHILDREN"><code>HAS_NO_CHILDREN</code></a>, to match the IMAP spelling.</p>
          <dt id="HAS_CHILDREN">HAS_CHILDREN
          <dd><p>The presence of this attribute indicates that the mailbox has child mailboxes. A server SHOULD NOT set this attribute if there are child mailboxes and the user does not have permission to access any of them.  In this case, <code>\HasNoChildren</code> SHOULD be used. In many cases, however, a server may not be able to efficiently compute whether a user has access to any child mailboxes. Note that even though the <code>\HasChildren</code> attribute for a mailbox must be correct at the time of processing the mailbox, a client must be prepared to deal with a situation when a mailbox is marked with the <code>\HasChildren</code> attribute, but no child mailbox appears in the response to the <a href="IMAP.html#method-i-list"><code>list</code></a> command. This might happen, for example, due to child mailboxes being deleted or made inaccessible to the user (using access control) by another client before the server is able to list them.</p>

<p>It is an error for the server to return both a <code>\HasChildren</code> and a <code>\HasNoChildren</code> attribute in the same <a href="IMAP.html#method-i-list"><code>list</code></a> response. A client that encounters a <a href="IMAP.html#method-i-list"><code>list</code></a> response with both <code>\HasChildren</code> and <code>\HasNoChildren</code> attributes present should act as if both are absent in the <a href="IMAP.html#method-i-list"><code>list</code></a> response.</p>
          <dt id="HAS_NO_CHILDREN">HAS_NO_CHILDREN
          <dd><p>The presence of this attribute indicates that the mailbox has NO child mailboxes that are accessible to the currently authenticated user.</p>

<p>It is an error for the server to return both a <code>\HasChildren</code> and a <code>\HasNoChildren</code> attribute in the same <a href="IMAP.html#method-i-list"><code>list</code></a> response. A client that encounters a <a href="IMAP.html#method-i-list"><code>list</code></a> response with both <code>\HasChildren</code> and <code>\HasNoChildren</code> attributes present should act as if both are absent in the <a href="IMAP.html#method-i-list"><code>list</code></a> response.</p>

<p>Note: the <code>\HasNoChildren</code> attribute should not be confused with the <code>\NoInferiors</code> attribute, which indicates that no child mailboxes exist now and none can be created in the future.</p>
          <dt id="MARKED">MARKED
          <dd><p>The mailbox has been marked “interesting” by the server; the mailbox probably contains messages that have been added since the last time the mailbox was selected.</p>

<p>If it is not feasible for the server to determine whether or not the mailbox is “interesting”, the server SHOULD NOT send either <code>\Marked</code> or <code>\Unmarked</code>. The server MUST NOT send more than one of <code>\Marked</code>, <code>\Unmarked</code>, and <code>\NoSelect</code> for a single mailbox, and it MAY send none of these.</p>
          <dt id="NOINFERIORS">NOINFERIORS
          <dd><p>Alias for <a href="IMAP.html#NO_INFERIORS"><code>NO_INFERIORS</code></a>, to match the IMAP spelling.</p>
          <dt id="NONEXISTENT">NONEXISTENT
          <dd><p>The <code>\NonExistent</code> attribute indicates that a mailbox name does not refer to an existing mailbox. Note that this attribute is not meaningful by itself, as mailbox names that match the canonical <a href="IMAP.html#method-i-list"><code>list</code></a> pattern but don’t exist must not be returned unless one of the two conditions listed below is also satisfied:</p>
<ol><li>
<p>The mailbox name also satisfies the selection criteria (for example, it is subscribed and the “SUBSCRIBED” selection option has been specified).</p>
</li><li>
<p>“RECURSIVEMATCH” has been specified, and the mailbox name has at least one descendant mailbox name that does not match the <a href="IMAP.html#method-i-list"><code>list</code></a> pattern and does match the selection criteria.</p>
</li></ol>

<p>In practice, this means that the <code>\NonExistent</code> attribute is usually returned with one or more of <code>\Subscribed</code>, <code>\Remote</code>, <code>\HasChildren</code>, or the CHILDINFO extended data item.</p>

<p>The client must treat the presence of the <code>\NonExistent</code> attribute as if the <code>\NoSelect</code> attribute was also sent by the server</p>
          <dt id="NOSELECT">NOSELECT
          <dd><p>Alias for <a href="IMAP.html#NO_SELECT"><code>NO_SELECT</code></a>, to match the IMAP spelling.</p>
          <dt id="NO_INFERIORS">NO_INFERIORS
          <dd><p>Mailbox attribute indicating it is not possible for any child levels of hierarchy to exist under this name; no child levels exist now and none can be created in the future children.</p>

<p>The client must treat the presence of the <code>\NoInferiors</code> attribute as if the <code>\HasNoChildren</code> attribute was also sent by the server</p>
          <dt id="NO_SELECT">NO_SELECT
          <dd><p>Mailbox attribute indicating it is not possible to use this name as a selectable mailbox.</p>
          <dt id="REMOTE">REMOTE
          <dd><p>The mailbox is a remote mailbox.</p>
          <dt id="SUBSCRIBED">SUBSCRIBED
          <dd><p>The mailbox name was subscribed to using the <a href="IMAP.html#method-i-subscribe"><code>subscribe</code></a> command.</p>
          <dt id="UNMARKED">UNMARKED
          <dd><p>The mailbox does not contain any additional messages since the last time the mailbox was selected.</p>

<p>If it is not feasible for the server to determine whether or not the mailbox is “interesting”, the server SHOULD NOT send either <code>\Marked</code> or <code>\Unmarked</code>. The server MUST NOT send more than one of <code>\Marked</code>, <code>\Unmarked</code>, and <code>\NoSelect</code> for a single mailbox, and it MAY send none of these.</p>
        </dl>
        </section>



              </section>
      <section id="Mailbox+role+attributes" class="documentation-section">
      <header class="documentation-section-title">
      <h2>
        Mailbox role attributes
      </h2>
      <span class="section-click-top">
        <a href="#top">&uarr; top</a>
      </span>
      </header>


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="ALL">ALL
          <dd><p>Mailbox attribute indicating that this mailbox presents all messages in the user’s message store. Implementations MAY omit some messages, such as, perhaps, those in Trash and Junk. When this special use is supported, it is almost certain to represent a virtual mailbox</p>
          <dt id="ARCHIVE">ARCHIVE
          <dd><p>Mailbox attribute indicating that this mailbox is used to archive messages. The meaning of an “archival” mailbox is server dependent; typically, it will be used to get messages out of the inbox, or otherwise keep them out of the user’s way, while still making them accessible</p>
          <dt id="DRAFTS">DRAFTS
          <dd><p>Mailbox attribute indicating that this mailbox is used to hold draft messages – typically, messages that are being composed but have not yet been sent. In some server implementations, this might be a virtual mailbox, containing messages from other mailboxes that are marked with the “Draft” message flag. Alternatively, this might just be advice that a client put drafts here</p>
          <dt id="JUNK">JUNK
          <dd><p>Mailbox attribute indicating that this mailbox is where messages deemed to be junk mail are held. Some server implementations might put messages here automatically.  Alternatively, this might just be advice to a client-side spam filter.</p>
          <dt id="SENT">SENT
          <dd><p>Mailbox attribute indicating that this mailbox is used to hold copies of messages that have been sent. Some server implementations might put messages here automatically. Alternatively, this might just be advice that a client save sent messages here.</p>
          <dt id="TRASH">TRASH
          <dd><p>Mailbox attribute indicating that this mailbox is used to hold messages that have been deleted or marked for deletion. In some server implementations, this might be a virtual mailbox, containing messages from other mailboxes that are marked with the <code>\Deleted</code> message flag. Alternatively, this might just be advice that a client that chooses not to use the IMAP <code>\Deleted</code> model should use as its trash location. In server implementations that strictly expect the IMAP <code>\Deleted</code> model, this special use is likely not to be supported.</p>
        </dl>
        </section>



              </section>
      <section id="System+Flags" class="documentation-section">
      <header class="documentation-section-title">
      <h2>
        System Flags
      </h2>
      <span class="section-click-top">
        <a href="#top">&uarr; top</a>
      </span>
      </header>


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="ANSWERED">ANSWERED
          <dd><p>Flag indicating a message has been answered.</p>
          <dt id="DELETED">DELETED
          <dd><p>Flag indicating a message has been marked for deletion.  This will occur when the mailbox is closed or expunged.</p>
          <dt id="DRAFT">DRAFT
          <dd><p>Flag indicating a message is only a draft or work-in-progress version.</p>
          <dt id="FLAGGED">FLAGGED
          <dd><p>A message flag indicating a message has been flagged for special or urgent attention.</p>

<p>Also a mailbox special use attribute, which indicates that this mailbox presents all messages marked in some way as “important”.  When this special use is supported, it is likely to represent a virtual mailbox collecting messages (from other mailboxes) that are marked with the “Flagged” message flag.</p>
          <dt id="RECENT">RECENT
          <dd><p>Flag indicating that the message is “recent,” meaning that this session is the first session in which the client has been notified of this message.</p>

<p>This flag was defined by <a href="https://www.rfc-editor.org/rfc/rfc3501.html">IMAP4rev1</a> and is deprecated by <a href="https://www.rfc-editor.org/rfc/rfc9051.html">IMAP4rev2</a>.</p>
          <dt id="SEEN">SEEN
          <dd><p>Flag indicating a message has been read.</p>
        </dl>
        </section>



              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>.</p><p><a href="https://jamesbritt.bandcamp.com/">Maximum R+D</a>.  </p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

